-
Notifications
You must be signed in to change notification settings - Fork 151
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
fix(blade): chipgroup grid alignment #2536
Changes from 28 commits
39da608
67b9d5f
fb84e53
2481620
1e89e97
72efaeb
18838c7
464acc8
f280c95
98296fb
7c9803a
f3633f3
a818274
dc6fa5a
23ee578
f4652cb
bb40a3f
62f74c1
2a32ed1
a1f66f9
c02f1e9
1836fdc
8adc366
3443de8
1774421
833b335
4be16b6
bf73016
eee166f
29bfc15
aad91c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@razorpay/blade': patch | ||
--- | ||
|
||
fix(blade): allow consumers to align chips in chipgroup |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -727,3 +727,82 @@ chipRef.parameters = { | |||||
exclude: ['icon'], | ||||||
}, | ||||||
}; | ||||||
|
||||||
export const CutomLayoutInChipGroup: StoryFn<typeof ChipGroupComponent> = () => { | ||||||
const chipArray = [ | ||||||
{ | ||||||
value: '100', | ||||||
label: '₹100', | ||||||
}, | ||||||
{ | ||||||
value: '500', | ||||||
label: '₹500', | ||||||
}, | ||||||
{ | ||||||
value: '1000', | ||||||
label: '₹1000', | ||||||
}, | ||||||
{ | ||||||
value: '2000', | ||||||
label: '₹2000', | ||||||
}, | ||||||
{ | ||||||
value: '5000', | ||||||
label: '₹5000', | ||||||
}, | ||||||
{ | ||||||
value: '10000', | ||||||
label: '₹10000', | ||||||
}, | ||||||
{ | ||||||
value: '20000', | ||||||
label: '₹20000', | ||||||
}, | ||||||
{ | ||||||
value: '50000', | ||||||
label: '₹50000', | ||||||
}, | ||||||
{ | ||||||
value: '100000', | ||||||
label: '₹100000', | ||||||
}, | ||||||
{ | ||||||
value: '200000', | ||||||
label: '₹200000', | ||||||
}, | ||||||
]; | ||||||
|
||||||
return ( | ||||||
<Box gap="spacing.3" display="flex" flexDirection="column"> | ||||||
<ChipGroupComponent | ||||||
selectionType="single" | ||||||
label="Select a gift card with value (without custom chipGroupContainerLayout)" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
what is chipGroupContainerLayout? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
> | ||||||
{chipArray.map((chip, index) => ( | ||||||
<ChipComponent key={index} value={chip.value}> | ||||||
{chip.label} | ||||||
</ChipComponent> | ||||||
))} | ||||||
</ChipGroupComponent> | ||||||
<ChipGroupComponent | ||||||
selectionType="single" | ||||||
label="Select a gift card with value (custom chipGroupContainerLayout)" | ||||||
> | ||||||
<Box | ||||||
display="grid" | ||||||
gridTemplateColumns="repeat(3, 1fr)" | ||||||
gridTemplateRows="repeat(3, minmax(0, 30px))" | ||||||
gap="spacing.3" | ||||||
> | ||||||
{chipArray.map((chip, index) => ( | ||||||
<ChipComponent key={index} value={chip.value} width="100%"> | ||||||
{chip.label} | ||||||
</ChipComponent> | ||||||
))} | ||||||
</Box> | ||||||
</ChipGroupComponent> | ||||||
</Box> | ||||||
); | ||||||
}; | ||||||
|
||||||
CutomLayoutInChipGroup.storyName = 'ChipGroup with Custom layout'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from 'react'; | ||
import { chipGroupGapTokens, chipGroupLabelSizeTokens } from './chipTokens'; | ||
import { chipGroupLabelSizeTokens, chipGroupGapTokens } from './chipTokens'; | ||
import { ChipGroupProvider } from './ChipGroupContext'; | ||
import { useChipGroup } from './useChipGroup'; | ||
import type { ChipGroupProps } from './types'; | ||
|
@@ -96,18 +96,15 @@ const _ChipGroup = ( | |
<VisuallyHidden> | ||
<Text>{accessibilityLabel}</Text> | ||
</VisuallyHidden> | ||
<BaseBox display="flex" flexDirection="row" flexWrap="wrap"> | ||
{React.Children.map(children, (child, index) => { | ||
return ( | ||
<BaseBox | ||
key={index} | ||
marginBottom={chipGroupGapTokens[size].bottom} | ||
marginRight={chipGroupGapTokens[size].right} | ||
> | ||
{child} | ||
</BaseBox> | ||
); | ||
})} | ||
<BaseBox | ||
display="flex" | ||
flexDirection="row" | ||
flexWrap="wrap" | ||
rowGap={chipGroupGapTokens[size].bottom} | ||
columnGap={chipGroupGapTokens[size].right} | ||
marginBottom={chipGroupGapTokens[size].bottom} | ||
> | ||
{children} | ||
Comment on lines
-99
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice 🏅 |
||
</BaseBox> | ||
<FormHint | ||
size={chipGroupLabelSizeTokens[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.
Sorry for one more comment 🙈 But shouldn't we be adding width styles to outermost element? In this the basebox that we have? and let Chip take its width?
That way you also won't have to do
getBaseBoxStyles
hack since its BaseBox itself where you can directly pass width props.Currently it feels too aggresive to add styles in style tag since they take very high priority. Plus I'm guessing it will break when I do
width={{ base: 'spacing.3', m: 'spacing.4' }}
since style tag won't support media query