-
Notifications
You must be signed in to change notification settings - Fork 184
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
[BD-7115] Add Section Header into Backpack #2912
Conversation
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
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.
Only other thing if you could please remove the flow tags as we don't need those anymore now that you've changed it to TS! 😄
.bpk-component-section-header { | ||
&--btn { | ||
display: flex; | ||
width: 36 * $bpk-one-pixel-rem; |
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.
You don't need this, as button has a iconOnly
prop so you don't need to set the width/height yourself 😄
<BpkButton | ||
className={cls('bpk-component-section-header--btn')} | ||
CommonProps={{ blank: false }} | ||
> |
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.
What is this prop used for?
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.
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 I remove CommonProps?
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.
Oh that's weird.. actually BpkButton is not written in TS. Instead you can use BpkButtonV2 which is the newer version and is written in TS as the old one will go away anyways 🙂
import { BpkButtonV2 } from '../../packages/bpk-component-button';
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.
CommonProps is not actually a prop, I guess the TS compiler gets a bit confused with importing a JS component into a TS file 🙁
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.
BpkButtonV2
works, thank you
|
||
import STYLES from './examples.module.scss'; | ||
|
||
const cls = cssModules(STYLES); |
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.
could you rename this to getClassName
just to align with the rest of the usages
|
||
export const ForMobile = MobileExample; | ||
|
||
export const VisualTestDefault = DefaultExample; |
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.
No need to have a visual test for each of these. Instead you can bundle them all into one example component that gets visually tested. We do this in most of our components for example - https://github.com/Skyscanner/backpack/blob/main/examples/bpk-component-badge/examples.js#L140
justify-content: space-between; | ||
align-items: flex-start; | ||
|
||
&--titleAndDesc { |
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 you rename this so that it uses kebab case for consistency? We don't use camel case
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
|
||
/* @flow strict */ | ||
|
||
import { get } from 'lodash'; |
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 don't think this is used?
| --------------------- |----------|----------| ------------- | | ||
| title | string | true | - | | ||
| description | string | false | - | | ||
| button | node | false | - | |
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 you also add the onDark prop here please? 😄
Can you also add the type declaration files |
@import '~bpk-mixins/index.scss'; | ||
|
||
.bpk-section-header-examples { | ||
&--on-dark { |
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.
If this is the first level, could use &__on-dark
like many other cases in backpack.
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.
Thank you for reviews, &--on-dark
is acceptable like BpkModalInner.module.scss
|
||
&--mixed { | ||
display: flex; | ||
grid-row-gap: $bpk-spacing-base; |
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.
Use bpk-spacing-base()
* limitations under the License. | ||
*/ | ||
|
||
/* @flow strict */ |
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 if changed into typescript, this kind of exegesis could be removed.
| title | string | true | - | | ||
| description | string | false | - | | ||
| button | node | false | - | | ||
| type | oneOf("default", "onDark") | false | default | |
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 be SECTION_TYPES.onDark
and SECTION_TYPES.default
<BpkSectionHeader | ||
title="Section title" | ||
description="Section title description" | ||
button={<BpkButton onClick={() => jest.fn()}>View more</BpkButton>} |
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.
Use BpkButtonV2
here to keep consistency?
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
* limitations under the License. | ||
*/ | ||
|
||
/* @flow strict */ |
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.
All of this should be deleted since you are already using TypeScript for the type checking but not Flow
<div | ||
className={getClassName( | ||
'bpk-section-header', | ||
onDark && 'bpk-section-header--on-dark', |
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.
onDark && 'bpk-section-header--on-dark', | |
`bpk-section-header--${SECTION_TYPES}`, |
&--default {
color: $bpk-text-primary-day;
}
&--onDark {
color: $bpk-text-on-dark-day;
}
This will make it look more concise
<div | ||
className={getClassName( | ||
'bpk-section-header--title-description', | ||
onDark && 'bpk-section-header--title-description--on-dark', |
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 here
it('should not have programmatically-detectable accessibility issues', async () => { | ||
const { container } = render(<BpkSectionHeader title="Section title" />); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); |
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.
Maybe you can also add a new one for including description
?
<div | ||
className={getClassName( | ||
'bpk-section-header', | ||
onDark && 'bpk-section-header--on-dark', |
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.
how about simply use 'bpk-section-header--dark'
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.
yes, I changed the onDark value as on-dark
, and use bpk-section-header--on-dark
}: Props) => { | ||
const onDark = type === SECTION_TYPES.onDark; | ||
return ( | ||
<div |
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.
Could we support Accessibility in this 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.
Perhaps we could add another prop as a label for the button? I don't think that the aria-label for text is needed as it's text and not an interactive element?
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.
button is a node, can we deal with the accessibility for it in the consumed micosite, then we don't need one more prop.
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.
@Supremeyh any thoughts from an accessibility perspective on what could be improved? 🙂
From my perspective the text elements should be fine as they are and do not need a label as labels should be used for interactive elements. The texts gets read out by screen readers. Button like Kathy said should be handled on the microsite
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.
Thanks @anambl and @KathyWang0208! It's great to hear that the text elements are already accessible, and interactive elements button can also support on microsite side. In this case, it's fine to me.
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
Visit https://backpack.github.io/storybook-prs/2912 to see this build running in a browser. |
###Changes
Figma link
Add backpack section header component
###Snapshots
Default
With description
With Full props
Remember to include the following changes:
README.md
(If you have created a new component)README.md