Skip to content
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

[Tag] Add secondary styling #12475

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 6 additions & 0 deletions .changeset/popular-gifts-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': minor
'polaris.shopify.com': minor
---

Add secondary variant to Tag component
4 changes: 4 additions & 0 deletions polaris-react/src/components/Tag/Tag.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
padding-right: 0;
padding-inline-end: 0;
}

&.secondary {
background-color: var(--p-color-bg-fill-secondary);
}
}

.Button {
Expand Down
25 changes: 25 additions & 0 deletions polaris-react/src/components/Tag/Tag.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Bleed,
BlockStack,
Text,
Card,
} from '@shopify/polaris';
import {WandIcon} from '@shopify/polaris-icons';

Expand Down Expand Up @@ -40,6 +41,9 @@ export const All = {
<br />
<Text as="p">Removable large</Text>
<RemovableLarge.render />
<br />
<Text as="p">Secondary</Text>
<Secondary.render />
</BlockStack>
/* eslint-enable react/jsx-pascal-case */
);
Expand Down Expand Up @@ -193,3 +197,24 @@ export const RemovableLarge = {
);
},
};

export const Secondary = {
render() {
return (
<Card>
<InlineStack gap="100">
<Tag secondary>Wholesale</Tag>
<Tag disabled secondary>
Disabled
</Tag>
<Tag secondary url="#">
With URL
</Tag>
<Tag secondary onRemove={() => {}}>
Removable
</Tag>
</InlineStack>
</Card>
);
},
};
4 changes: 4 additions & 0 deletions polaris-react/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface NonMutuallyExclusiveProps {
url?: string;
/** The size of the tag */
size?: 'large';
/** Apply secondary styling */
secondary?: boolean;
}

export type TagProps = NonMutuallyExclusiveProps &
Expand All @@ -40,6 +42,7 @@ export function Tag({
accessibilityLabel,
url,
size,
secondary,
}: TagProps) {
const i18n = useI18n();

Expand All @@ -52,6 +55,7 @@ export function Tag({
url && !disabled && styles.linkable,
segmented && styles.segmented,
size && styles[variationName('size', size)],
secondary && styles.secondary,
);

let tagTitle = accessibilityLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ examples:
- fileName: tag-removable-large.tsx
title: Removable large
description: A larger, removable attribute to an object that allows merchants to navigate to a resource.
- fileName: tag-secondary.tsx
title: Secondary
description: A less promenant variation of the default tag.
previewImg: /images/components/selection-and-input/tag.png
---

Expand Down
15 changes: 15 additions & 0 deletions polaris.shopify.com/pages/examples/tag-secondary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Card, Tag, LegacyStack} from '@shopify/polaris';
import React from 'react';
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';

function TagExample() {
return (
<Card>
<LegacyStack spacing="tight">
<Tag secondary>Secondary</Tag>
</LegacyStack>
</Card>
);
}

export default withPolarisExample(TagExample);
Loading