-
Notifications
You must be signed in to change notification settings - Fork 233
feat(badge, progress-circle): s2 styling and render #5718
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
base: barebones
Are you sure you want to change the base?
Conversation
|
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Tachometer resultsCurrently, no packages are changed by this PR... |
5bc7ac2
to
b2f7410
Compare
b2f7410
to
76955a7
Compare
return html` | ||
<slot @slotchange=${this.handleSlotchange}></slot> |
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.
For the sake of simplifying this for S2, I've regressed some of this functionality by removing the slot and leveraging our SVG approach. Would love to have a larger conversation around this for S2 but this seemed sufficient for the base requirement of getting the S2 styles and rendering into the component.
*/ | ||
@property({ reflect: true, attribute: 'static-color' }) | ||
public staticColor?: 'white'; | ||
public staticColor?: 'white' | 'black'; |
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.
This is an example where S1 supports only static color white and S2 has styles for static color white & black. What's the current thinking on handling that?
* Stroke width for the progress circle. | ||
*/ | ||
@property({ type: Number, reflect: false }) | ||
public get strokeWidth(): number { |
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.
This seems a nicer API than the current but would be good to have a discussion re: handling the evolution of the APIs between S1 & S2. S2 progress circle could have a new strokeWidth customization and eschew the current makeRotation function in favor of letting CSS do the calculations (sans transformation).
typeof this.fixed !== 'undefined', | ||
})} | ||
> | ||
${when( |
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 updated the ternary to use when
instead but let me know if there's a reason not to use that here.
</div> | ||
` | ||
)} | ||
<div class="spectrum-Badge-label"> |
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 tested adding this class to the slot itself and it didn't render padding correctly. Maybe just a case of needing the appropriate display settings but I didn't dig into it too much. Would be good to have a standard "best practice" in place for whether we want to wrap slots to apply styles or style slot containers directly.
@@ -37,6 +37,11 @@ export const BADGE_VARIANTS = [ | |||
'green', | |||
'cyan', | |||
'blue', | |||
'pink', |
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.
Another question here on handling new variant options. S1 badge has variants but not styles for these additional options. How do we want to handle extending this and adding the new options for S2-only?
* @property {boolean} subtle - Whether the badge is subtle. | ||
* @property {boolean} outline - Whether the badge is outlined. |
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.
Subtle & outline are new to S2
|
||
public set fixed(fixed: FixedValues | undefined) { |
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.
This seems to me to be how the @Property works by default. I don't see any regressions when I simplify this but let me know if I've missed a nuance here.
@@ -139,7 +139,7 @@ export const Indeterminate: Story = { | |||
export const StaticWhite: Story = { | |||
render: () => html` | |||
<div | |||
style="background-color: rgba(0,0,0,0.4); padding: 24px; display: flex; gap: 24px; align-items: center;" | |||
style="background: linear-gradient(45deg, rgb(64 0 22), rgb(14 24 67)); padding: 24px; display: flex; gap: 24px; align-items: center;" |
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.
Added our pretty gradients here for static white/black which match how design demos these styles. They're meant to be on visually busy backgrounds like gradients or images so that drives home that guidance in Storybook as well.
@@ -189,9 +216,3 @@ export const IndeterminateStaticWhite: Story = { | |||
</div> | |||
`, | |||
}; | |||
|
|||
export const WithSlottedContent: Story = { |
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 removed the slot for the purposes of my S2 update but we can always bring this back.
|
||
import { ProgressCircleBase } from '@swc/core/components/progress-circle'; | ||
|
||
import progressCircleStyles from './progress-circle.css'; | ||
|
||
function capitalize(str?: string): 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.
I kind of liked this utility living separately but let me know how you want to handle this in the SWC infrastructure.
@@ -16,13 +16,16 @@ import { SizedMixin, SpectrumElement } from '@swc/core/shared/base'; | |||
import { ObserveSlotPresence } from '@swc/core/shared/observe-slot-presence'; | |||
import { ObserveSlotText } from '@swc/core/shared/observe-slot-text'; | |||
|
|||
export const BADGE_VARIANTS = [ | |||
export const BADGE_VARIANTS_SEMANTIC = [ |
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.
Separating out the semantic variants from the color variants helps us in Storybook (and possibly down the road) because only semantic variants support outline styling.
@@ -37,11 +40,11 @@ export const BADGE_VARIANTS = [ | |||
'green', | |||
'cyan', | |||
'blue', | |||
'pink', |
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 these don't exist in S1, I removed these additions and moved them into the S2 component file as an extension of the existing base.
@@ -55,8 +58,6 @@ export type FixedValues = (typeof FIXED_VALUES)[number]; | |||
/** | |||
* @element sp-badge-base | |||
* @property {BadgeVariant} variant - The variant of the badge. | |||
* @property {boolean} subtle - Whether the badge is subtle. |
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.
This only exists in S2's new styles so I'm testing out moving these into the S2-only component.
BadgeBase, | ||
} from '@swc/core/components/badge'; | ||
|
||
export const BADGE_VARIANTS_COLOR = [ |
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.
This re-exports the const with the addition of the new colors.
...BADGE_VARIANTS_SEMANTIC, | ||
...BADGE_VARIANTS_COLOR, | ||
] as const; | ||
export type BadgeVariant = (typeof BADGE_VARIANTS)[number]; |
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'm not sure if I need to redefine this since technically it's the same but the content of the BADGE_VARIANTS has changed so I went ahead and did that.
@@ -49,8 +57,9 @@ export type FixedValues = (typeof FIXED_VALUES)[number]; | |||
|
|||
/** | |||
* @element sp-badge-base | |||
* @slot - The text label to display in the badge. |
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 this doesn't have a render, should we define these only on the render layer?
e00d4cc
to
3924d40
Compare
public set strokeWidth(customWidth: unknown) { | ||
if (customWidth && customWidth instanceof Number) { | ||
this._strokeWidth = customWidth as number; | ||
} | ||
|
||
this._strokeWidth = this.size === 's' ? 2 : this.size === 'l' ? 4 : 3; | ||
} |
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.
public set strokeWidth(customWidth: unknown) {
if (customWidth && customWidth instanceof Number) {
this._strokeWidth = customWidth as number;
this._customStrokeWidth = true;
} else {
this._strokeWidth =
this.size === 's' ? 2 : this.size === 'l' ? 4 : 3;
this._customStrokeWidth = false;
}
}
I like the addition of customWidth, not sure how we'd introduce this concept though.
For now, I'm just exploring how to get the svg to fit within the parent container.
this._strokeWidth = this.size === 's' ? 2 : this.size === 'l' ? 4 : 3; | ||
} | ||
|
||
private _strokeWidth: number = 2; |
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.
private _strokeWidth: number = 3;
private _customStrokeWidth: boolean = false;
Again, maybe you have a better idea, but trying to figure out why the changes weren't updating.
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.
in protected override update
I added this to update the stroke width per shirt size:
// Update stroke width when size changes (if no custom width was set)
if (changes.has('size') && !this._customStrokeWidth) {
// Force recalculation by calling the setter
this.strokeWidth = undefined;
}
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! Great points. We need to be accounting for those changes so we can trigger repaint.
@castastrophe The S2 addition of these are sooooo lovely!! I'd love to contribute to this!! |
Description
Motivation and context
Related issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch
,minor
, ormajor
featuresManual review test cases
Descriptive Test Statement
Descriptive Test Statement
Device review