-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat: Migrate all attributes to lowercase ('smushedcase'). #537
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -1,31 +1,16 @@ | |||
import type { NextPage } from 'next'; |
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.
NOTE: Need to revert this. Hold over from presentation testing.
src/js/index.d.ts
Outdated
@@ -0,0 +1,200 @@ | |||
export * as constants from "./constants.js"; |
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.
NOTE: Going to drop this in this PR, but this was the quick fix solution to get all of the TypeScript types in place for React. We should instead just completely revamp how the React wrappers work in our v1.0 effort.
@@ -129,14 +129,14 @@ class MediaChromeButton extends window.HTMLElement { | |||
enable() { | |||
this.addEventListener('click', this.#clickListener); | |||
this.addEventListener('keydown', this.#keydownListener); | |||
this.setAttribute('tabindex', '0'); | |||
this.tabIndex = 0; |
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.
NOTE: Moving to using the tabIndex
prop instead for forward-looking dreams.
src/js/media-container.js
Outdated
* if gestures are disabled, don't accept pointer-events | ||
*/ '' | ||
} | ||
:host(:not([${Attributes.AUDIO}])[${ |
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.
oof formatter really did a number on this one. Will unmangle.
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.
can this be formatted similar to how it was?
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.
yessir!
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.
which formatter did this? yarn format
?
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.
I think it was some default prettier line length creeping in? Haven't investigated.
src/js/media-container.js
Outdated
} | ||
:host([${Attributes.USER_INACTIVE}]:not([${ | ||
MediaUIAttributes.MEDIA_PAUSED | ||
}]):not([${MediaUIAttributes.MEDIA_IS_CASTING}]):not([${ |
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.
same for this uggo.
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.
yup
src/js/media-time-display.js
Outdated
@@ -12,8 +19,8 @@ const ButtonPressedKeys = ['Enter', ' ']; | |||
const DEFAULT_TIMES_SEP = ' / '; | |||
|
|||
const formatTimesLabel = (el, { timesSep = DEFAULT_TIMES_SEP } = {}) => { | |||
const showRemaining = el.getAttribute('remaining') != null; | |||
const showDuration = el.getAttribute('show-duration') != null; | |||
const showRemaining = el.showRemaining; |
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.
NOTE: This feels like scope creep for this round. Hoping for a gut check from others if you think I should drop it (still around in other branches).
@@ -102,7 +102,7 @@ template.innerHTML = /*html*/` | |||
align-items: start; | |||
} | |||
|
|||
:host([control-bar-place$="end"]) media-control-bar { | |||
:host([controlbarplace$="end"]) media-control-bar { |
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.
NOTE: Should discuss - normalize so official attrs for official themes are also lowercase/"smushedcase" (See below for at least one particular friction point/tradeoff).
@@ -440,7 +440,7 @@ template.innerHTML = /*html*/` | |||
</template> | |||
|
|||
<media-controller | |||
style="--_control-bar-place-self:{{controlBarPlace ?? 'unset'}}" | |||
style="--_control-bar-place-self:{{controlbarplace ?? 'unset'}}" |
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.
NOTE: Because we use JS to translate attr -> prop, using all lowercase/"smushedcase" here doesn't allow us to use camelCase
to translate (since there are no delimiters to match against with the new names).
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.
We may want to treat this as a separate effort and descope it for this initial round of changes.
src/js/media-playback-rate-button.js
Outdated
]; | ||
} | ||
|
||
/** @type number[] | undefined */ | ||
#_rates; |
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.
can we leave the underscore, use #rates
instead?
don't really see a reason for an added underscore.
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.
Yup we can def drop the underscore. ❤️
src/js/media-time-display.js
Outdated
/** @type boolean | undefined */ | ||
#_showDuration; | ||
/** @type boolean | undefined */ | ||
#_remaining; |
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.
here too the underscores
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.
Will either remove or rename before merging, depending on team decision here.
src/js/media-playback-rate-button.js
Outdated
@@ -60,12 +63,22 @@ class MediaPlaybackRateButton extends MediaChromeButton { | |||
super.attributeChangedCallback(attrName, oldValue, newValue); | |||
} | |||
|
|||
get rates() { |
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.
this seems like scope-creep.
This getter should return a DOMTokenList, while the setter should accept an array.
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.
Cool I agree let's just drop all of the property changes in this PR. @luwes when we re-add we'll be sure to account for your private variable naming convention prefs.
Codecov Report
@@ Coverage Diff @@
## main #537 +/- ##
==========================================
- Coverage 76.41% 76.38% -0.03%
==========================================
Files 43 43
Lines 7056 7141 +85
==========================================
+ Hits 5392 5455 +63
- Misses 1664 1686 +22
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -25,7 +25,7 @@ | |||
"build:iife": "esbuild src/js/index.js --bundle --target=es2019 --format=iife --outdir=dist/iife --minify --sourcemap --global-name=MediaChrome && yarn size", | |||
"build:react": "node ./scripts/react/build.js", | |||
"build:manifest": "npx @custom-elements-manifest/analyzer analyze --config scripts/custom-elements-manifest.config.js", | |||
"build": "yarn build:esm && yarn build:cjs && yarn build:iife && yarn build:react && yarn build:types && yarn build:manifest", | |||
"build": "yarn build:types && yarn build:esm && yarn build:cjs && yarn build:iife && yarn build:react && yarn build:manifest", |
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.
NOTE: switch the order to ensure types are available before build (for dev watch behavior/expectations)
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.
pre-approving, just need to fix the CSS formatting a little bit
// NOTE: Adding for TypeScript Errors. Followup should add correct getter/setter & private var (CJP) | ||
/** @type number[] | undefined */ | ||
_rates; |
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.
is this used anywhere?
@@ -35,7 +40,7 @@ const setBackgroundImage = (el, image) => { | |||
|
|||
class MediaPosterImage extends window.HTMLElement { | |||
static get observedAttributes() { | |||
return ['placeholder-src', 'src']; | |||
return [Attributes.PLACEHOLDER_SRC, Attributes.SRC]; |
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.
non-blocker: alternative is to do Object.values(Attributes)
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.
decided to not use values just because that's "incidental" and not "definitional" (aka all of the values in Attributes
happen to be observedAttributes
, but that could change and isn't inherent to their relationship).
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.
Ah, right. Worked here incidentally. Wasn't a blocker or necessary anyway.
Migrates all well-defined attributes in Media Chrome elements from kebab-case to lowercase (aka "smushedcase").