Comments (12)
@nielslyngsoe you may also want to look at this example to render relative time, which also use Intl.RelativeTimeFormat
API: https://shoelace.style/components/relative-time
from umbraco.ui.
FYI, GitHub (the org) has a bundle of elements that extend the native <time>
element:
<local-time>
, <relative-time>
and <time-ago>
https://github.com/github/time-elements
I found these on the Awesome Standalones repo, (for framework-agnostic standalone web components).
from umbraco.ui.
@warrenbuckley not yet, so feel free start working on this :)
from umbraco.ui.
@nielslyngsoe I just saw this on Twitter: https://twitter.com/Steve8708/status/1504131981444980739
Maybe a similar utility function?
Not sure what it return right after midnight though.
from umbraco.ui.
@leekelleher that's probably a good idea to extend the native <time>
element.
It also use Intl.RelativeTimeFormat
API as well via some utility methods:
https://github.com/github/time-elements/blob/main/src/utils.ts#L166-L179
Update: I think these functions were moved to here: https://github.com/github/relative-time-element/blob/main/src/relative-time-element.ts#L116-L200
from umbraco.ui.
@bjarnef you planning on working this, if not I may try and give this a go :)
from umbraco.ui.
@warrenbuckley great that you'd like to take a stab at it! FYI, the component should handle the lang
attribute directly as well as observe the lang
attribute set on the browser element through the global variable known as document.documentElement.lang
. I'm not sure if the Intl API picks up on this automatically. In the backoffice at least, we have to listen for changes to that attribute.
from umbraco.ui.
@iOvergaard the component could probably observe document lang
attribute, but not sure if there's a need to specify a different language than backoffice language (or if used in other contexts). I this this Shoelace component may use default language in
https://shoelace.style/components/relative-time#localization
I think they handled English as the default/fallback language as part of the localization utility.
https://github.com/shoelace-style/shoelace/blob/7500cabc587abead71f2440ad8f87aa4c1f468f9/src/utilities/localize.ts#L2
Not sure if the localization in UI library or backoffice is aware of the locale/culture, but also other stuff like direction (LTR / RTL).
https://www.w3.org/International/questions/qa-html-dir
It seems the direction in that library was defined in each language:
https://github.com/shoelace-style/shoelace/blob/7500cabc587abead71f2440ad8f87aa4c1f468f9/src/utilities/localize.ts#L14
from umbraco.ui.
not sure if there's a need to specify a different language than backoffice language
No, probably not, but how does it get the backoffice language. Does the Intl Api get it from the lang attribute automatically?
from umbraco.ui.
@iOvergaard this project https://github.com/github/relative-time-element seems to get language from closest lang
attribute: https://github.com/github/relative-time-element/blob/main/src/relative-time-element.ts#L84-L90
Regarding Intl.RelativeTimeFormat()
I think it use en
if locale is not provided.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat
from umbraco.ui.
Lang is a built-in global attribute. Relative Time will use this to provide an applicable language to the Intl APIs. If the individual element does not have a lang attribute then it will traverse upwards in the tree to find the closest element that does, or default the lang to en.
https://github.com/github/relative-time-element#lang
from umbraco.ui.
@bjarnef you seem to be more active on this and realistically with my workload and little free time I doubt I will get to this, so if you have been working on this please feel free to as I won't be right now.
from umbraco.ui.
Related Issues (20)
- uui-button: primary buttons and focus issues
- uui-button: Button not shown with icons
- uui-toggle: icons doesn't look great HOT 2
- uui-swatch: checkmark has too low contrast on light colors HOT 3
- uui-swatch: selection no longer works with space key HOT 3
- uui-combobox more padding for options HOT 1
- uui-combobox reconsider home and end-buttons
- uui-combobox click to close does not work
- Git commit issue when folder has blank space
- Ensure same padding around text in pagination HOT 2
- Storybook navigation broken on mobile? HOT 3
- Tabs do not conform to W3 Accesibility pattern
- Tab group does not support gap property.
- Links should support the `rel` attribute HOT 2
- Focus on selected item when opening combobox with a combobox list HOT 1
- UUI-Combobox does not display properly in Safari
- `:focus-visible` state hardly visible on uui-button element with `color="primary"` HOT 1
- Support transition on uui-button
- Support border for uui-box
- Support different backgroud colors for uui-menu-item
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from umbraco.ui.