-
Notifications
You must be signed in to change notification settings - Fork 14
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(806) container queries and storybook #877
base: main
Are you sure you want to change the base?
Conversation
You can preview these changes on: |
package.json
Outdated
"@emotion/react": "^11.1.5", | ||
"@emotion/styled": "^11.10.4", | ||
"@emotion/react": "^11.10.5", | ||
"@emotion/styled": "^11.10.5", |
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 these changes no longer work with lower versions of emotion? Do note that we have emotion versions specified in the peerDependencies
for consumers and this will likely need to be upped.
It's a bit grey to me if this would actually make this a breaking change or not. Given it's only a minor version bump on a dependency we could argue it isn't... but I guess there is still some level of risk for consumers who are upgrading.
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 didn't work on the version we had, and required the bump. I'm not sure which specific minimum version it's in. I could narrow that down. But ultimately, it does require moving to a higher emotion version to use container queries
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.
11.10.4
will be the lowest supported version can we please update the peer dependencies?
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.
also I think it should be sub 12 not the thin range that it's currently specified to
src/grid-layout/types.ts
Outdated
} & LogicalProps; | ||
} & Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>; | ||
} & ContainerQueryProps & |
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.
should this live at the same level as the logical props? e.g. in the overrides?
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.
Addressed in the latest commit
@@ -7,3 +7,19 @@ export type MQPartial<T> = Partial<{ | |||
}>; | |||
|
|||
export type MQ<T> = T | MQPartial<T>; | |||
|
|||
export type ResponsiveValue<T> = MQ<T> | CSSQueryRules<T>; |
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 add a description to these news types, it should make it easier for consumers to understand what they are looking at.
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.
Sure thing
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 need to update the docs site as well so that reflects these changes.
👏 This is cool |
overrides={{ | ||
containerName: 'container-small', | ||
containerType: 'inline-size', | ||
}} |
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.
Block does not have overrides, these need to be props. I think the same apply to the other componnets
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.
Originally I had them as props, @jps suggested moving them into overrides - to be the same level as logical props
Ideally would keep them consistent across all components
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.
Well, the thing is that Block does not have overrides, so the logical props on the Block are props, <Block marginInline />
GridLayout has overrides (which was wrong) and in that case they can be part of the overrides
src/card-composable/__tests__/__stories/card-composable.stories.tsx
Outdated
Show resolved
Hide resolved
src/grid-layout/types.ts
Outdated
@@ -11,7 +11,8 @@ export type GridLayoutItemProps = BlockProps & { | |||
alignSelf?: MQ<string>; | |||
column?: MQ<string>; | |||
row?: MQ<string>; | |||
} & React.HTMLAttributes<HTMLElement>; | |||
} & ContainerQueryProps & |
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.
The Block already have these as "overrides' which I mentioned need to be just props.
And this is adding it second time,
src/grid-layout/types.ts
Outdated
minHeight?: ResponsiveValue<string>; | ||
maxHeight?: ResponsiveValue<string>; | ||
} & LogicalProps & | ||
ContainerQueryProps; |
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 as block -> move to props
@@ -7,3 +7,19 @@ export type MQPartial<T> = Partial<{ | |||
}>; | |||
|
|||
export type MQ<T> = T | MQPartial<T>; | |||
|
|||
export type ResponsiveValue<T> = MQ<T> | CSSQueryRules<T>; |
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 need to update the docs site as well so that reflects these changes.
@param value - CSS value or token | ||
*/ | ||
export type CSSQuery<T> = { | ||
rule: `@media ${string}` | `@container ${string}`; |
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.
that's very clever ;)
marginBlockStart?: MQ<string>; | ||
marginBlockEnd?: MQ<string>; | ||
marginBlock?: MQ<string>; | ||
marginInlineStart?: ResponsiveValue<string>; |
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.
One slight concern here is this now implies all components with logical props now support container queries and it won't be clear to users which is actually do. Maybe we just have to bite the bullet for now and the other components can be updated soon as aware this PR could keep growing.
Just a reminder we are going to need to update the docs also to reflect the change from MQ to ResponsiveValue
> = usedValues.reduce( | ||
(acc: Record<CSSQuery<T>['rule'], string | CSSObject>, prop) => { | ||
const values = {} as {[Key in keyof T]: T[Key]}; | ||
if (prop[1].rules) { |
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.
minor but this condition can be pulled up to a filter, to reduce nestings
@@ -55,7 +55,7 @@ describe('GridLayout', () => { | |||
const props: GridLayoutProps = { | |||
areas: ` | |||
"A A" | |||
"B C" | |||
"B C" |
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.
😬
Since we are changing PEER DEPS I am not sure if that's not a breaking change for all users |
closes #806
What
Background - why this is needed
Allows users to add custom media queries and container queries into props/overrides
What did you do
What does the reviewers should expect
This adds a new style to the page with emotion that handles the container query
I have done:
I have tested manually:
Before:
After:
Who should review this PR:
How to test: