Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/@adobe/spectrum-css-temp/components/badge/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ governing permissions and limitations under the License.

/* label should always have padding at the end */
.spectrum-Badge-label {
order: 1; /* always be after the icon, regardless of DOM order */
padding-inline-end: var(--spectrum-global-dimension-size-115);
}

.spectrum-Badge-icon {
flex-shrink: 0;
order: 0; /* always be before the label, regardless of DOM order */
padding-inline-start: var(--spectrum-global-dimension-size-115);
}
/* icon + text buttons should have padding between the text and icon no matter the order */
.spectrum-Badge-icon + .spectrum-Badge-label {
padding-inline-start: var(--spectrum-global-dimension-size-65);
padding-inline-start: var(--spectrum-global-dimension-size-100);
}

.spectrum-Badge-label:not([hidden]) + .spectrum-Badge-icon {
padding-inline-end: var(--spectrum-global-dimension-size-115);
padding-inline-end: var(--spectrum-global-dimension-size-100);
}

/* text only buttons should have padding at the start */
Expand Down
14 changes: 14 additions & 0 deletions packages/@react-spectrum/badge/chromatic/Badge.chromatic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ export const IconText: BadgeStory = {
args: {children: <><CheckmarkCircle /><Text>Badge text</Text></>},
render: renderVariants
};

export const TextIcon: BadgeStory = {
name: 'Text & icon',
args: {children: <><Text>Badge text</Text><CheckmarkCircle /></>},
render: renderVariants
};

export const Overflow: BadgeStory = {
args: {children: '24 days left in trial', variant: 'positive', UNSAFE_style: {width: '74px'}}
};

export const OverflowWithIcon: BadgeStory = {
args: {children: <><CheckmarkCircle /><Text>24 days left in trial</Text></>, variant: 'positive', UNSAFE_style: {width: '74px'}}
};
5 changes: 5 additions & 0 deletions packages/@react-spectrum/badge/stories/Badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export const WithIcon: BadgeStory = {
name: 'With icon'
};

export const WithIconReverseOrder: BadgeStory = {
args: {children: <><Text>Licensed</Text><CheckmarkCircle /></>, variant: 'positive'},
name: 'With icon, order reversed'
};

export const IconOnly: BadgeStory = {
args: {children: <CheckmarkCircle />, variant: 'positive', 'aria-label': 'Licensed'},
name: 'Icon only'
Expand Down