-
Notifications
You must be signed in to change notification settings - Fork 5
fix(skins): slightly more idiomatic Tailwind, added custom properties #175
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mihar-22
left a comment
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.
Awesome, thank you! Only a few notes in addition to review:
- Worth a discussion with the team on whether we'll use
media-orvjs-prefix. We should be consistent with our custom element prefix. - Can we drop
styles.tsand move all styles directly into markup? Good step towards being more idiomatic, don't thinkstyles.tsis a recognized pattern in TW-land. I understand we did it for early compiler goals and testing. - Can we drop manual addition of
vjs:utility prefix? Create a new temporary utility in skin files which callscnand adds prefix for us. Temporary because we'll have an official vanilla CSS import not generted with TW compiler as it is today. I'm assuming the TW compiler doesn't require this prefix to be statically analyzable when set?
| MediaContainer: cn( | ||
| 'vjs', // Scope preflight | ||
| 'vjs:relative vjs:isolate vjs:@container/root vjs:group/root vjs:overflow-clip vjs:bg-black', | ||
| 'vjs:relative vjs:isolate vjs:@container/root vjs:group/root vjs:overflow-clip vjs:bg-black vjs:rounded-(--vjs-border-radius,2rem)', |
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 we should extend the theme to support this value? Something like --radius-chrome which would be vjs:rounded-chrome? Alternative could be brand, theme, or vjs. Similar comment with font family and other config vars.
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 was aiming to avoid having folks extend or change their configuration ideally. It just creates a complexity that's a bit too much for some and then we get support requests asking why it doesn't look right. That said, it works for Shadcn but perhaps that's because it's a wider component library rather than a single component. Probably a discussion point.
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.
It also raises the question of how the compiler would handle it but perhaps we just have known aspects that we have to handle separately.
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.
Ye I think similar to shadcn we would just have these included either manually or codemod when the skin is added via CLI. Worth a discussion for sure. I think if we're building a design system as part of Tailwind then this is something we should do idiomatically and avoid littering vars inline. It's also something the compiler could/should extract from the config into vanilla CSS. Again, love to chat more about it :)
| // Hide when playing (for now). | ||
| // ------------------------------------ | ||
| // FIXME: This is crude temporary logic, we'll improve it later I guess with a [data-show-controls] attribute or something? | ||
| 'vjs:has-[+.controls_[data-paused]]:opacity-100 vjs:has-[+.controls_[data-paused]]:delay-0 vjs:has-[+.controls_[data-paused]]:duration-100', |
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.
Usage of has here is a code smell to me that we need a Overlay (maybe different name, Scrim?) component with it's own data 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.
Agree with the general sentiment. If MediaContainer had all properties by default, would that work?
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.
Yeah, I've anticipated all of this controls hide/show logic this is temporary. Having a dedicated component would be ideal. Backdrop might be another suitable name perhaps (aligns with the native <dialog> backdrop etc).
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.
Ye we would need a dedicated component to avoid relying on parent state to style this elmenet which is breaking encapsulation.
| // ------------------------------------ | ||
| // FIXME: Temporary hide/show logic | ||
| 'vjs:scale-90 vjs:opacity-0 vjs:blur-sm vjs:delay-500 vjs:duration-300', | ||
| 'vjs:has-[[data-paused]]:scale-100 vjs:has-[[data-paused]]:opacity-100 vjs:has-[[data-paused]]:blur-none vjs:has-[[data-paused]]:delay-0 vjs:has-[[data-paused]]:duration-100', |
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.
Similar to overlay, code smell to me that we need a Controls component, which we actually do anyway.
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.
Agreed. This is temporary logic again.
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, worth a callout here in terms of not being idiomatic or breaking encapsulation. I wasn't expecting to fix in this PR. I'll have tickets up for these eventually.
| 'vjs:[&_.play-tooltip]:hidden vjs:[&[data-paused]_.play-tooltip]:inline', | ||
| ), | ||
| PlayTooltip: cn('play-tooltip'), | ||
| PauseTooltip: cn('pause-tooltip'), |
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 should be able to remove these semantic classes now as the compiler won't need them since we discovered the design system loader. Similar comment with others like it in this file.
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.
Yeah, we can possibly remove them later once we have the compiler but they're currently needed to hide/show the correct content.
For me, the most idiomatic approach (in React, at least) for the tooltip content would be conditional rendering:
{isPlaying ? t('PAUSE') : t('PLAY')}(assuming we have a t function for i18n at some point).
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 imagine few ways we can handle this:
- Use the
renderfunction on thePlayButtonto access state and render tooltip content accordingly inside. I don't mind this but it does feel funny with tooltip inside the button. - Use a hook like you've mentioned. We can just pluck state from media store or package up a more specific hook so devs don't need to guess which state they need. Imperative approach and more barebones.
PlayTooltipcomponent and use data attrs for showing/hiding. Declarative approach and exposes styling hooks.
I like 3 because it's consitent with other tooltips structurally and we can expose additional data attributes for styling. Doesn't preclude us from having the hook as well. It's similar to how we have different versions of "toggle" buttons like play, mute, captions, etc. I originally wasn't a fan but the more I think about it, makes sense.
|
--vjs-border-radiusto all skins so that border radius can be baked in but controlled a little easier by consumers.--vjs-font-familyto HTML skins so we set a default font family. The assumption being that the Tailwind users would have a font stack set to inherit from. I'm open to discussion on this.