-
Notifications
You must be signed in to change notification settings - Fork 195
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
chore(button,link): add more static color tests #3374
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,130 @@ | ||
import { Variants } from "@spectrum-css/preview/decorators"; | ||
import { html } from "lit"; | ||
import { capitalize } from "lodash-es"; | ||
import { ArgGrid, Container, Variants } from "@spectrum-css/preview/decorators"; | ||
import { Template } from "./template.js"; | ||
|
||
/** | ||
* Multiple button variations displayed in one story template. | ||
* Used as the base template for the stories. | ||
*/ | ||
const CustomButton = ({ iconName, iconSet, ...args }, context) => html` | ||
<div style="display: flex; column-gap: 13px; row-gap: 24px;"> | ||
${Template({ | ||
const ButtonContentGroup = ({ iconName, iconSet, ...args }, context) => Container({ | ||
level: 3, | ||
withBorder: false, | ||
content: [ | ||
Template({ | ||
...args, | ||
iconName: undefined, | ||
}, context)} | ||
${Template({ | ||
}, context), | ||
Template({ | ||
...args, | ||
iconName: iconName ?? "Edit", | ||
iconSet: iconSet ?? "workflow", | ||
}, context)} | ||
${Template({ | ||
}, context), | ||
Template({ | ||
...args, | ||
hideLabel: true, | ||
iconName: iconName ?? "Edit", | ||
iconSet: iconSet ?? "workflow", | ||
}, context)} | ||
</div> | ||
`; | ||
}, context), | ||
], | ||
}); | ||
|
||
const ButtonIconGroup = (args, context) => Container({ | ||
level: 3, | ||
withBorder: false, | ||
content:[ | ||
{ | ||
testHeading: "Workflow icon", | ||
content: Template({ | ||
...args, | ||
iconName: "Edit", | ||
iconSet: "workflow", | ||
}, context), | ||
}, | ||
{ | ||
testHeading: "Workflow icon", | ||
content: Template({ | ||
...args, | ||
iconName: "Link", | ||
iconSet: "workflow", | ||
}, context), | ||
}, | ||
{ | ||
testHeading: "UI icon", | ||
content: Template({ | ||
...args, | ||
// Uses a UI icon that is smaller than workflow sizing, to test alignment: | ||
iconName: "Cross100", | ||
iconSet: "ui", | ||
}, context), | ||
}, | ||
{ | ||
testHeading: "UI icon (larger)", | ||
content: Template({ | ||
...args, | ||
// UI icon that is larger than workflow sizing: | ||
iconName: "ArrowDown600", | ||
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. Similar thinking here. ✨ |
||
iconSet: "ui", | ||
}, context), | ||
}, | ||
], | ||
}); | ||
|
||
const ButtonTreatmentGroup = (args, context) => ArgGrid({ | ||
Template: ButtonContentGroup, | ||
withBorder: false, | ||
withWrapperBorder: false, | ||
argKey: "treatment", | ||
labels: { | ||
fill: "", | ||
outline: "", | ||
}, | ||
...args, | ||
}, context); | ||
|
||
const ButtonVariantGroup = (args, context) => ArgGrid({ | ||
Template: ButtonTreatmentGroup, | ||
withBorder: false, | ||
argKey: "variant", | ||
...args, | ||
}, context); | ||
|
||
export const ButtonGroups = Variants({ | ||
Template: CustomButton, | ||
Template: ButtonContentGroup, | ||
testData: [ | ||
...["accent", "negative", "primary", "secondary"].map((variant) => ({ | ||
testHeading: capitalize(variant), | ||
variant, | ||
})), | ||
// Note: In Spectrum 2, outline buttons are no longer available in accent and negative options. | ||
...["accent", "negative", "primary", "secondary"].map((variant) => ({ | ||
testHeading: capitalize(variant) + " - outline", | ||
variant, | ||
treatment: "outline", | ||
})), | ||
{ | ||
testHeading: "Static black", | ||
staticColor: "black", | ||
Template: ButtonVariantGroup, | ||
}, | ||
{ | ||
Template: ButtonVariantGroup, | ||
testHeading: "Static white", | ||
staticColor: "white", | ||
}, | ||
{ | ||
testHeading: "Text wrapping with workflow icon", | ||
customStyles: { | ||
"max-inline-size": "480px", | ||
}, | ||
iconName: "Edit", | ||
iconSet: "workflow", | ||
label: "An example of text overflow behavior within the button component. When the button text is too long for the horizontal space available, it wraps to form another line.", | ||
withStates: false, | ||
Template, | ||
Template: ButtonVariantGroup, | ||
testHeading: "Static black", | ||
staticColor: "black", | ||
}, | ||
{ | ||
testHeading: "Text wrapping with UI icon", | ||
Template: ButtonIconGroup, | ||
testHeading: "Line wrap", | ||
customStyles: { | ||
"max-inline-size": "480px", | ||
}, | ||
// Uses a UI icon that is smaller than workflow sizing, to test alignment: | ||
iconName: "Cross100", | ||
iconSet: "ui", | ||
iconName: "Edit", | ||
iconSet: "workflow", | ||
label: "An example of text overflow behavior within the button component. When the button text is too long for the horizontal space available, it wraps to form another line.", | ||
withStates: false, | ||
Template, | ||
}, | ||
{ | ||
testHeading: "Disable label wrapping", | ||
customStyles: { | ||
"max-inline-size": "120px", | ||
}, | ||
label: "Be a premium member", | ||
noWrap: true, | ||
withStates: false, | ||
Template, | ||
}, | ||
{ | ||
testHeading: "Disable label wrapping with workflow icon", | ||
Template: ButtonIconGroup, | ||
testHeading: "Truncation", | ||
customStyles: { | ||
"max-inline-size": "120px", | ||
}, | ||
iconName: "Star", | ||
iconName: "Edit", | ||
iconSet: "workflow", | ||
label: "Be a premium member", | ||
withStates: false, | ||
noWrap: true, | ||
Template, | ||
}, | ||
{ | ||
testHeading: "Text wrapping with larger UI icon", | ||
customStyles: { | ||
"max-inline-size": "480px", | ||
}, | ||
// UI icon that is larger than workflow sizing: | ||
iconName: "ArrowDown600", | ||
iconSet: "ui", | ||
label: "An example of text overflow behavior within the button component. When the button text is too long for the horizontal space available, it wraps to form another line.", | ||
withStates: false, | ||
Template, | ||
}, | ||
], | ||
stateData: [ | ||
|
@@ -126,7 +147,7 @@ export const ButtonGroups = Variants({ | |
{ | ||
testHeading: "Pending", | ||
isPending: true, | ||
ignore: ["Static black"], | ||
ignore: ["Static black", "Static white"], | ||
}, | ||
], | ||
sizeDirection: "row", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 most minor of nits but I'd be inclined to remove
:
as we can assume the comment pertains to the line(s) that follow. ✨