-
Notifications
You must be signed in to change notification settings - Fork 1
fix(flex): ensure utility styles override component styles (DS-5175) #438
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cfc84d7
fix(flex): ensure utility styles override component styles
KamilEmeleev acf74f7
fix(flex): ensure utility styles override component styles (round 2)
KamilEmeleev ddea296
chore: approve api
KamilEmeleev 7da6e58
test(flex): cover zero order value
KamilEmeleev e38993e
style(flex): use type-only import for FlexProps
KamilEmeleev 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
199 changes: 199 additions & 0 deletions
199
packages/components/src/components/FlexBox/FlexBox.module.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,199 @@ | ||
| .base { | ||
| --flex-type: flex; | ||
| --flex-wrap: nowrap; | ||
| --flex-direction: row; | ||
| --flex-align-items: flex-start; | ||
| --flex-justify-content: flex-start; | ||
|
|
||
| gap: var(--flex-row-gap) var(--flex-column-gap); | ||
| display: var(--flex-type); | ||
| align-items: var(--flex-align-items); | ||
| justify-content: var(--flex-justify-content); | ||
| flex-flow: var(--flex-direction) var(--flex-wrap); | ||
| } | ||
|
KamilEmeleev marked this conversation as resolved.
|
||
|
|
||
| .alignItems_flex-start { | ||
| --flex-align-items: flex-start; | ||
| } | ||
|
|
||
| .alignItems_flex-end { | ||
| --flex-align-items: flex-end; | ||
| } | ||
|
|
||
| .alignItems_center { | ||
| --flex-align-items: center; | ||
| } | ||
|
|
||
| .alignItems_baseline { | ||
| --flex-align-items: baseline; | ||
| } | ||
|
|
||
| .alignItems_stretch { | ||
| --flex-align-items: stretch; | ||
| } | ||
|
|
||
| .justifyContent_flex-start { | ||
| --flex-justify-content: flex-start; | ||
| } | ||
|
|
||
| .justifyContent_flex-end { | ||
| --flex-justify-content: flex-end; | ||
| } | ||
|
|
||
| .justifyContent_center { | ||
| --flex-justify-content: center; | ||
| } | ||
|
|
||
| .justifyContent_space-between { | ||
| --flex-justify-content: space-between; | ||
| } | ||
|
|
||
| .justifyContent_space-around { | ||
| --flex-justify-content: space-around; | ||
| } | ||
|
|
||
| .justifyContent_space-evenly { | ||
| --flex-justify-content: space-evenly; | ||
| } | ||
|
|
||
| .flex_flex { | ||
| --flex-type: flex; | ||
| } | ||
|
|
||
| .flex_inline-flex { | ||
| --flex-type: inline-flex; | ||
| } | ||
|
|
||
| .wrap_wrap { | ||
| --flex-wrap: wrap; | ||
| } | ||
|
|
||
| .wrap_nowrap { | ||
| --flex-wrap: nowrap; | ||
| } | ||
|
|
||
| .wrap_wrap-reverse { | ||
| --flex-wrap: wrap-reverse; | ||
| } | ||
|
|
||
| .direction_row { | ||
| --flex-direction: row; | ||
| } | ||
|
|
||
| .direction_row-reverse { | ||
| --flex-direction: row-reverse; | ||
| } | ||
|
|
||
| .direction_column { | ||
| --flex-direction: column; | ||
| } | ||
|
|
||
| .direction_column-reverse { | ||
| --flex-direction: column-reverse; | ||
| } | ||
|
|
||
| /* column-gap */ | ||
| .gap_column_3xs { | ||
| --flex-column-gap: var(--kbq-size-3xs); | ||
| } | ||
|
|
||
| .gap_column_xxs { | ||
| --flex-column-gap: var(--kbq-size-xxs); | ||
| } | ||
|
|
||
| .gap_column_xs { | ||
| --flex-column-gap: var(--kbq-size-xs); | ||
| } | ||
|
|
||
| .gap_column_s { | ||
| --flex-column-gap: var(--kbq-size-s); | ||
| } | ||
|
|
||
| .gap_column_m { | ||
| --flex-column-gap: var(--kbq-size-m); | ||
| } | ||
|
|
||
| .gap_column_l { | ||
| --flex-column-gap: var(--kbq-size-l); | ||
| } | ||
|
|
||
| .gap_column_xl { | ||
| --flex-column-gap: var(--kbq-size-xl); | ||
| } | ||
|
|
||
| .gap_column_xxl { | ||
| --flex-column-gap: var(--kbq-size-xxl); | ||
| } | ||
|
|
||
| .gap_column_3xl { | ||
| --flex-column-gap: var(--kbq-size-3xl); | ||
| } | ||
|
|
||
| .gap_column_4xl { | ||
| --flex-column-gap: var(--kbq-size-4xl); | ||
| } | ||
|
|
||
| .gap_column_5xl { | ||
| --flex-column-gap: var(--kbq-size-5xl); | ||
| } | ||
|
|
||
| .gap_column_6xl { | ||
| --flex-column-gap: var(--kbq-size-6xl); | ||
| } | ||
|
|
||
| .gap_column_7xl { | ||
| --flex-column-gap: var(--kbq-size-7xl); | ||
| } | ||
|
|
||
| /* row-gap */ | ||
| .gap_row_3xs { | ||
| --flex-row-gap: var(--kbq-size-3xs); | ||
| } | ||
|
|
||
| .gap_row_xxs { | ||
| --flex-row-gap: var(--kbq-size-xxs); | ||
| } | ||
|
|
||
| .gap_row_xs { | ||
| --flex-row-gap: var(--kbq-size-xs); | ||
| } | ||
|
|
||
| .gap_row_s { | ||
| --flex-row-gap: var(--kbq-size-s); | ||
| } | ||
|
|
||
| .gap_row_m { | ||
| --flex-row-gap: var(--kbq-size-m); | ||
| } | ||
|
|
||
| .gap_row_l { | ||
| --flex-row-gap: var(--kbq-size-l); | ||
| } | ||
|
|
||
| .gap_row_xl { | ||
| --flex-row-gap: var(--kbq-size-xl); | ||
| } | ||
|
|
||
| .gap_row_xxl { | ||
| --flex-row-gap: var(--kbq-size-xxl); | ||
| } | ||
|
|
||
| .gap_row_3xl { | ||
| --flex-row-gap: var(--kbq-size-3xl); | ||
| } | ||
|
|
||
| .gap_row_4xl { | ||
| --flex-row-gap: var(--kbq-size-4xl); | ||
| } | ||
|
|
||
| .gap_row_5xl { | ||
| --flex-row-gap: var(--kbq-size-5xl); | ||
| } | ||
|
|
||
| .gap_row_6xl { | ||
| --flex-row-gap: var(--kbq-size-6xl); | ||
| } | ||
|
|
||
| .gap_row_7xl { | ||
| --flex-row-gap: var(--kbq-size-7xl); | ||
| } | ||
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
48 changes: 48 additions & 0 deletions
48
packages/components/src/components/layout/flex/flex.test.ts
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,48 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { flex } from './flex'; | ||
| import s from './flex.module.css'; | ||
|
|
||
| describe('flex', () => { | ||
| it('should generate classes for every flex property', () => { | ||
| expect( | ||
| flex( | ||
| { | ||
| flex: 'inline-flex', | ||
| wrap: 'wrap-reverse', | ||
| order: -1, | ||
| gap: 'm', | ||
| rowGap: 'l', | ||
| colGap: 'xl', | ||
| direction: 'column-reverse', | ||
| alignItems: 'center', | ||
| justifyContent: 'space-between', | ||
| }, | ||
| 'custom-class' | ||
| ) | ||
| ).toBe( | ||
| [ | ||
| s.base, | ||
| s['flex_inline-flex'], | ||
| s['wrap_wrap-reverse'], | ||
| s['order_-1'], | ||
| s.gap_row_l, | ||
| s.gap_column_xl, | ||
| s['direction_column-reverse'], | ||
| s.alignItems_center, | ||
| s['justifyContent_space-between'], | ||
| 'custom-class', | ||
| ].join(' ') | ||
| ); | ||
| }); | ||
|
|
||
| it('should use gap as the row and column gap fallback', () => { | ||
| expect(flex({ gap: 'm' })).toBe( | ||
| [s.base, s.gap_row_m, s.gap_column_m].join(' ') | ||
| ); | ||
| }); | ||
|
|
||
| it('should generate class for zero order', () => { | ||
| expect(flex({ order: 0 })).toBe([s.base, s.order_0].join(' ')); | ||
| }); | ||
| }); | ||
|
KamilEmeleev marked this conversation as resolved.
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.