-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add suggested time component with strings #8423
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
|
||
<div class="time-context"> | ||
<div v-if="time > 0"> | ||
{{ $tr('shortTime', { time: 120 }) }} | ||
</div> | ||
<div v-if="time > 0"> | ||
{{ $tr('suggestedTimeLabel', { time: 120 }) }} | ||
</div> | ||
{{ $tr('suggestedTimeTooltip') }} | ||
</div> | ||
|
||
</template> | ||
|
||
|
||
<script> | ||
|
||
export default { | ||
name: 'SuggestedTime', | ||
props: { | ||
/* Time in ms */ | ||
time: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
}, | ||
$trs: { | ||
suggestedTimeTooltip: { | ||
message: 'Suggested time to complete', | ||
context: | ||
'A tooltip explaning what the clock icon and time indicates about the resource they are viewing', | ||
}, | ||
shortTime: { | ||
message: '{time} {time, plural, one {minute} other {minutes}}', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These do need to be translated - you're not using any time related syntax here, this is just a simple If we use this string and it is not translated, we will end up with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that and figured that when I come back to it (post strings-getting-in rush) then I'll conditionalize showing any strings at all on whether or not we have > 0 passed in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah - I already had it conditionalized. @radinamatic - I think that TimeDuration will work the best but it isn't accurate - it rounds down so 2hrs 45min would show "2 hours". If @jtamiace and @rtibbles are okay with the way it rounds, then this component can be the "Suggested time to complete:" followed by the TimeDuration component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood, thank you @nucleogenesis! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if it's an issue we can probably further conditionalize TimeDuration to round up rather than down? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems okay for now since it still gives a ballpark about expected length, but I'd hope accuracy is something we can improve in the future. Any issue I can foresee is around planning and scheduling around learning with limited time and the resource taking longer than they expected, but I can't imagine that causing too many issues because it's just an estimate and people will engage resources at their own discernment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And I totally misread that, and thought that 1:45h was rounded to 2h... 🤦🏽♀️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We can also conditionalize the TimeDuration component's threshold for when it starts displaying 'hours', so we could make it display whole minutes for up to 120 minutes, and only then start displaying hours. Once we get past 120 minutes, hopefully any time durations are very ballpark anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just pushed it up with only the "Suggested time to complete" string. In follow up I can use TimeDuration to get things looking how we want - but at this point this should be a go for strings I think. Anybody feel free to force push anything you need to get this merged! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the update - and apologies for brigading your tiny PR! |
||
context: 'Converts the time given into internationalized time. Nothing to translate here.', | ||
}, | ||
suggestedTimeLabel: { | ||
message: 'Suggested time to complete: {time} {time, plural, one {minute} other {minutes}}', | ||
context: | ||
"Indicates to the user the suggested time the resource should take to complete. The '# minutes' string is internationalized automatically", | ||
}, | ||
}, | ||
}; | ||
|
||
</script> | ||
|
||
|
||
<style scoped lang="scss"></style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nucleogenesis Is there a way to reuse the existing
minute/minutes
string from the TimeDuration component?If I'm understanding correctly, you could even combine the
suggestedTimeTooltip
message with the existingminutes
fromTimeDuration
component to achieve the purpose ofsugestedTimeLabel
, and effectively need to stub just one string here 😉