-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: add Delineator
component
#25610
Conversation
default: | ||
return TextColor.textAlternative; | ||
} | ||
}; |
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.
Nit: Above function can be a simple object key -> value could be DelineatorType -> TextColor
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.
Good call but then default value needs to be determined by an ||
operator.
const textColorMap = {
[DelineatorType.Error]: TextColor.errorDefault,
};
/// usage
textColorMap[type] || TextColor.textAlternative;
{overrideTextComponentColorByType({ | ||
component: headerComponent, | ||
type, | ||
})} |
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.
Here is it not possible to pass color prop without cloning the component ?
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 am actually not fan of this but there is no way to override that property rather than this.
Normally the parent needs to set the <Text>
component color becuase they also set the type
. However this is an extra security to override whatever send in headerComponent
Do you think we should remove this and let parent set the color?
// Normal usage
<Delineator
headerComponent={
<Text
color={TextColor.textAlternative}
marginLeft={1}
variant={TextVariant.bodySm}
>
Insights from <b>Forta</b>
</Text>
}
iconName={IconName.Wallet}
>
Content
</Delineator>
// Error usage - Actually expected the text color to be send in error color
<Delineator
type="error"
headerComponent={
<Text
color={TextColor.errorDefault}
marginLeft={1}
variant={TextVariant.bodySm}
>
Insights from <b>Forta</b>
</Text>
}
iconName={IconName.Wallet}
>
Content
</Delineator>
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 agree that this component setting the colour is best since it enforces the consistent styling, plus believe cloning is best practice to override child properties.
}; | ||
} | ||
return { ...defaultIconProps, ...iconProps }; | ||
}; |
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.
Is it possible to have icon without iconsProps as inverseIconColorProp
? backgroundColor seems to be only property changing above.
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.
Good call, adrdressed this in 7b0a644
onExpandChange, | ||
type, | ||
wrapperBoxProps, | ||
}) => { |
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 it be required to have props isExpanded
, onExpandChange
one level above. Or they can be part of this component itself ?
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 it will create unnecessary state management overload where this component is used if we leave the expand
state to parent. I've added onExpandChange
because I saw that SnapsDelineator
needs such callback (probably for metrics etc)
45de3ec
to
7340067
Compare
{overrideTextComponentColorByType({ | ||
component: headerComponent, | ||
type, | ||
})} |
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 agree that this component setting the colour is best since it enforces the consistent styling, plus believe cloning is best practice to override child properties.
Builds ready [12500e4]
Page Load Metrics (146 ± 151 ms)
Bundle size diffs
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #25610 +/- ##
===========================================
+ Coverage 69.77% 69.81% +0.03%
===========================================
Files 1376 1380 +4
Lines 48403 48628 +225
Branches 13348 13407 +59
===========================================
+ Hits 33773 33945 +172
- Misses 14630 14683 +53 ☔ View full report in Codecov by Sentry. |
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.
looks good
d5f38f1
Quality Gate passedIssues Measures |
Builds ready [d5f38f1]
Page Load Metrics (155 ± 179 ms)
Bundle size diffs
|
Description
This PR aims to add
Delineator
component which heavily influenced bySnapsDelineator
with small visual differences and decoupled from snaps context.Related issues
Fixes: #24995
Manual testing steps
This component has no usage for now, hence it could be seen in the storybook.
yarn storybook
Delineator
component to see it visuallyScreenshots/Recordings
Pre-merge author checklist
Pre-merge reviewer checklist