-
Notifications
You must be signed in to change notification settings - Fork 12
⚠️ [WB-2327] Phase 3 — Port wonder-blocks-styles action styles to a CSS mixin #3100
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
Draft
jandrade
wants to merge
1
commit into
deploy/css-modules
Choose a base branch
from
WB-2327
base: deploy/css-modules
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| "@khanacademy/wonder-blocks-styles": minor | ||
| --- | ||
|
|
||
| Add a CSS-mixin counterpart to the `actionStyles` JS export so CSS | ||
| Modules authors can opt into the same interactive-control styling | ||
| without Aphrodite (WB-2327, Phase 3). A new package subpath, | ||
| `@khanacademy/wonder-blocks-styles/action-styles.css`, ships the | ||
| `--wb-action-inverse` mixin (mirroring `actionStyles.inverse`), which | ||
| expands into the control's nested `:hover` / `:focus-visible` / | ||
| `:active` rules and reuses the shared `--wb-focus-visible` ring. | ||
|
|
||
| This is purely additive — the existing Aphrodite-shaped `actionStyles` | ||
| and `focusStyles` JS exports are unchanged and remain available for | ||
| packages that have not migrated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
packages/wonder-blocks-styles/src/styles/action-styles.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Cross-package action-style mixins. | ||
| * | ||
| * Mirrors the Aphrodite-shaped `actionStyles` JS exports so CSS Modules | ||
| * authors can opt into the same interactive-control styling without | ||
| * pulling in Aphrodite. | ||
| * | ||
| * Authors include a mixin via: | ||
| * | ||
| * @import "@khanacademy/wonder-blocks-styles/action-styles.css"; | ||
| * | ||
| * .my-control { | ||
| * @apply --wb-action-inverse; | ||
| * } | ||
| * | ||
| * postcss-import resolves the @import through the workspace and | ||
| * @csstools/postcss-mixins expands the @apply at build time | ||
| * (CSS Mixins Level 1 syntax — note the leading `--` on the name). | ||
| */ | ||
|
|
||
| /* | ||
| * Pull in `--wb-focus-visible` so `--wb-action-inverse` can reuse the shared | ||
| * focus ring (parity with the JS `inverse` style, which spreads `focus`). | ||
| * postcss-import dedupes by resolved path, so consumers that also import | ||
| * focus-styles.css directly won't get a duplicate definition. | ||
| */ | ||
| @import "./focus-styles.css"; | ||
|
|
||
| /* | ||
| * The inverse styles for an interactive control, for special cases where the | ||
| * element sits on a dark background. | ||
| * | ||
| * NOTE: This mirrors `actionStyles.inverse`, which is slated to be deprecated | ||
| * in the future. | ||
| * | ||
| * The `&` selectors below have no scoping root at the mixin *definition* | ||
| * site, but they resolve to the consumer's selector once the mixin is | ||
| * `@apply`-ed inside a rule. Stylelint can't see that context, so the | ||
| * `nesting-selector-no-missing-scoping-root` rule is disabled for the block. | ||
| */ | ||
| /* stylelint-disable nesting-selector-no-missing-scoping-root */ | ||
| @mixin --wb-action-inverse() { | ||
| /* | ||
| * Overriding border-color only to preserve the visual integrity of the | ||
| * control, as there might be some cases where the interactive element | ||
| * already includes a border. | ||
| */ | ||
| &:not([aria-disabled="true"]) { | ||
| border-color: var(--wb-semanticColor-core-border-knockout-default); | ||
| color: var(--wb-semanticColor-core-foreground-knockout-default); | ||
| } | ||
|
|
||
| &:hover:not([aria-disabled="true"]) { | ||
| color: var(--wb-semanticColor-core-foreground-knockout-default); | ||
|
|
||
| /* | ||
| * Overriding border-color only to preserve the visual integrity of | ||
| * the control, as there might be some cases where the interactive | ||
| * element already includes a border. | ||
| */ | ||
| border-color: var(--wb-semanticColor-core-border-knockout-default); | ||
| } | ||
|
|
||
| /* Use the shared focus styles to keep the focus state consistent. */ | ||
| &:focus-visible { | ||
| @apply --wb-focus-visible; | ||
| } | ||
|
|
||
| &:active:not([aria-disabled="true"]) { | ||
| border-radius: var(--wb-border-radius-radius_080); | ||
|
|
||
| /* A slightly darker color than the inverse border color. */ | ||
| border-color: color-mix( | ||
| in srgb, | ||
| var(--wb-semanticColor-core-border-neutral-default) 55%, | ||
| var(--wb-semanticColor-core-border-knockout-default) | ||
| ); | ||
| background: color-mix( | ||
| in srgb, | ||
| var(--wb-semanticColor-core-background-base-default) 5%, | ||
| transparent | ||
| ); | ||
| } | ||
| } | ||
| /* stylelint-enable nesting-selector-no-missing-scoping-root */ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@mixin --wb-action-inverse()in the publishedwonder-blocks-stylesshared library, mirroringactionStyles.inverse. It expands into nested:hover/:focus-visible/:activerules and reuses--wb-focus-visible. Source-distributed (raw, likefocus-styles.css) so the@mixinsurvives un-expanded until the consumer build runs its own postcss-import → postcss-mixins chain. Additive only — the existing Aphrodite-shaped JS exports are untouched, so no consumer is affected.