From d326d183771211ee8281a435af914c25d6ee6646 Mon Sep 17 00:00:00 2001
From: langermank <18661030+langermank@users.noreply.github.com>
Date: Tue, 20 Dec 2022 10:01:23 -0800
Subject: [PATCH 1/5] update prop names, counter as prop
---
docs/content/ActionMenu.mdx | 8 +++---
docs/content/Button.mdx | 21 ++++++----------
src/Button/Button.features.stories.tsx | 18 ++++++-------
src/Button/Button.stories.tsx | 8 +++---
src/Button/ButtonBase.tsx | 25 +++++++++++++------
src/Button/ButtonCounter.tsx | 17 -------------
src/Button/LinkButton.features.stories.tsx | 4 +--
src/Button/LinkButton.stories.tsx | 8 +++---
src/Button/index.ts | 5 +---
src/Button/types.ts | 4 +--
src/PageHeader/PageHeader.stories.tsx | 2 +-
src/PageHeader/examples.stories.tsx | 4 +--
src/UnderlineNav2/styles.ts | 2 +-
src/__tests__/Button.types.test.tsx | 4 +--
src/drafts/MarkdownEditor/_Footer.tsx | 4 +--
src/drafts/MarkdownEditor/_ViewSwitch.tsx | 2 +-
src/stories/ActionMenu/examples.stories.tsx | 10 ++++----
src/stories/ActionMenu/fixtures.stories.tsx | 4 +--
src/stories/Overlay.stories.tsx | 2 +-
src/stories/deprecated/ActionMenu.stories.tsx | 2 +-
20 files changed, 68 insertions(+), 86 deletions(-)
delete mode 100644 src/Button/ButtonCounter.tsx
diff --git a/docs/content/ActionMenu.mdx b/docs/content/ActionMenu.mdx
index 937a06a07d2..78654d5ac89 100644
--- a/docs/content/ActionMenu.mdx
+++ b/docs/content/ActionMenu.mdx
@@ -182,7 +182,7 @@ const fieldTypes = [
{icon: NumberIcon, name: 'Number'},
{icon: CalendarIcon, name: 'Date'},
{icon: SingleSelectIcon, name: 'Single select'},
- {icon: IterationsIcon, name: 'Iteration'}
+ {icon: IterationsIcon, name: 'Iteration'},
]
const Example = () => {
@@ -191,7 +191,7 @@ const Example = () => {
return (
-
+
{selectedType.name}
@@ -275,7 +275,7 @@ render(
-
+ ,
)
```
@@ -368,7 +368,7 @@ render(
stableApi: true,
addressedApiFeedback: false,
hasDesignGuidelines: true,
- hasFigmaComponent: true
+ hasFigmaComponent: true,
}}
/>
diff --git a/docs/content/Button.mdx b/docs/content/Button.mdx
index 75de1bd279f..549e6379137 100644
--- a/docs/content/Button.mdx
+++ b/docs/content/Button.mdx
@@ -66,11 +66,11 @@ It is recommended to use an octicon here.
```jsx live
<>
-
-
-
+
{selectedOption ? `Group by ${selectedOption.text}` : 'Group items by'}
diff --git a/src/stories/ActionMenu/fixtures.stories.tsx b/src/stories/ActionMenu/fixtures.stories.tsx
index b0bf0b445cc..70701010381 100644
--- a/src/stories/ActionMenu/fixtures.stories.tsx
+++ b/src/stories/ActionMenu/fixtures.stories.tsx
@@ -64,7 +64,7 @@ export function ActionsStory(): JSX.Element {
Actions
-
+
@@ -548,7 +548,7 @@ export function MemexAddColumn(): JSX.Element {
-
+
{selectedType.name}
diff --git a/src/stories/Overlay.stories.tsx b/src/stories/Overlay.stories.tsx
index d26b57ab871..fac71ecdd70 100644
--- a/src/stories/Overlay.stories.tsx
+++ b/src/stories/Overlay.stories.tsx
@@ -306,7 +306,7 @@ export const NestedOverlays = () => {
variant="invisible"
ref={secondaryButtonRef}
sx={{px: 2, mx: 2, display: 'flex'}}
- leadingIcon={PlusIcon}
+ leadingVisual={PlusIcon}
onClick={() => setCreateListOverlayOpen(!createListOverlayOpen)}
>
Create list
diff --git a/src/stories/deprecated/ActionMenu.stories.tsx b/src/stories/deprecated/ActionMenu.stories.tsx
index c269dd642e8..ed4b2b98343 100644
--- a/src/stories/deprecated/ActionMenu.stories.tsx
+++ b/src/stories/deprecated/ActionMenu.stories.tsx
@@ -196,7 +196,7 @@ export function ComplexListStory(): JSX.Element {
groupId: '1',
renderItem: props => ,
trailingText: '⌘S', // backward compatible
- trailingIcon: ArrowRightIcon, // backward compatible
+ trailingVisual: ArrowRightIcon, // backward compatible
},
{
leadingVisual: NoteIcon,
From 660374662b712b2a15284aa2cbb3ffd02220efb2 Mon Sep 17 00:00:00 2001
From: langermank <18661030+langermank@users.noreply.github.com>
Date: Tue, 20 Dec 2022 11:29:11 -0800
Subject: [PATCH 2/5] remove outline variant
---
docs/content/Button.mdx | 8 ----
src/Button/Button.features.stories.tsx | 2 -
src/Button/LinkButton.features.stories.tsx | 6 ---
src/Button/styles.ts | 43 ----------------------
src/Button/types.ts | 2 +-
5 files changed, 1 insertion(+), 60 deletions(-)
diff --git a/docs/content/Button.mdx b/docs/content/Button.mdx
index 549e6379137..d8284b7623d 100644
--- a/docs/content/Button.mdx
+++ b/docs/content/Button.mdx
@@ -29,14 +29,6 @@ The `danger` variant of `Button` is used to warn users about potentially destruc
Danger
```
-### Outline button
-
-The `outline` variant of `Button` is typically used as a secondary button
-
-```jsx live
-Outline
-```
-
### Invisible button
The `invisible` variant of `Button` indicates that the action is a low priority one.
diff --git a/src/Button/Button.features.stories.tsx b/src/Button/Button.features.stories.tsx
index c789a4eb72f..532d166161f 100644
--- a/src/Button/Button.features.stories.tsx
+++ b/src/Button/Button.features.stories.tsx
@@ -14,8 +14,6 @@ export const Danger = () => Danger
export const Invisible = () => Invisible
-export const Outline = () => Outline
-
export const LeadingVisual = () => Leading visual
export const TrailingVisual = () => Trailing visual
diff --git a/src/Button/LinkButton.features.stories.tsx b/src/Button/LinkButton.features.stories.tsx
index f3e0e390ac4..e01f73112a4 100644
--- a/src/Button/LinkButton.features.stories.tsx
+++ b/src/Button/LinkButton.features.stories.tsx
@@ -30,12 +30,6 @@ export const Invisible = () => (
)
-export const Outline = () => (
-
- Invisible
-
-)
-
export const LeadingVisual = () => (
Leading visual
diff --git a/src/Button/styles.ts b/src/Button/styles.ts
index 55f82740a3c..42e9b32a331 100644
--- a/src/Button/styles.ts
+++ b/src/Button/styles.ts
@@ -131,49 +131,6 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
color: 'btn.text',
},
},
- outline: {
- color: 'btn.outline.text',
- boxShadow: `${theme?.shadows.btn.shadow}`,
- borderColor: 'btn.border',
- backgroundColor: 'btn.bg',
-
- '&:hover:not([disabled])': {
- color: 'btn.outline.hoverText',
- backgroundColor: 'btn.outline.hoverBg',
- borderColor: 'btn.outline.hoverBorder',
- boxShadow: `${theme?.shadows.btn.outline.hoverShadow}`,
- '[data-component=ButtonCounter]': {
- backgroundColor: 'btn.outline.hoverCounterBg',
- color: 'inherit',
- },
- },
- '&:active:not([disabled])': {
- color: 'btn.outline.selectedText',
- backgroundColor: 'btn.outline.selectedBg',
- boxShadow: `${theme?.shadows.btn.outline.selectedShadow}`,
- borderColor: 'btn.outline.selectedBorder',
- },
-
- '&:disabled': {
- color: 'btn.outline.disabledText',
- backgroundColor: 'btn.outline.disabledBg',
- borderColor: 'btn.border',
- '[data-component=ButtonCounter]': {
- backgroundColor: 'btn.outline.disabledCounterBg',
- color: 'inherit',
- },
- },
- '[data-component=ButtonCounter]': {
- backgroundColor: 'btn.outline.counterBg',
- color: 'btn.outline.text',
- },
- '&[aria-expanded=true]': {
- color: 'btn.outline.selectedText',
- backgroundColor: 'btn.outline.selectedBg',
- boxShadow: `${theme?.shadows.btn.outline.selectedShadow}`,
- borderColor: 'btn.outline.selectedBorder',
- },
- },
}
return style[variant]
}
diff --git a/src/Button/types.ts b/src/Button/types.ts
index 50f8d6a4f9d..61406888446 100644
--- a/src/Button/types.ts
+++ b/src/Button/types.ts
@@ -9,7 +9,7 @@ export const StyledButton = styled.button`
${sx};
`
-export type VariantType = 'default' | 'primary' | 'invisible' | 'danger' | 'outline'
+export type VariantType = 'default' | 'primary' | 'invisible' | 'danger'
export type Size = 'small' | 'medium' | 'large'
From c081858ad5407fa0de0840ddf70d024c3cd8fddc Mon Sep 17 00:00:00 2001
From: Katie Langerman <18661030+langermank@users.noreply.github.com>
Date: Tue, 20 Dec 2022 11:31:22 -0800
Subject: [PATCH 3/5] Create cyan-needles-melt.md
---
.changeset/cyan-needles-melt.md | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 .changeset/cyan-needles-melt.md
diff --git a/.changeset/cyan-needles-melt.md b/.changeset/cyan-needles-melt.md
new file mode 100644
index 00000000000..50ba08cfec0
--- /dev/null
+++ b/.changeset/cyan-needles-melt.md
@@ -0,0 +1,7 @@
+---
+"@primer/react": major
+---
+
+- Changes `leadingIcon` and `trailingIcon` to `leadingVisual` and `trailingVisual`
+- Removes `Button.Counter` as a child component, replacing it with a `count` prop. This change allows us to use the `trailingVisual` slot for counters.
+- Removes the `outline` button variant as we wish to only support `invisible` buttons.
From c53a94acb35774c168d8be9a04469ead90fc562b Mon Sep 17 00:00:00 2001
From: langermank <18661030+langermank@users.noreply.github.com>
Date: Tue, 20 Dec 2022 11:36:15 -0800
Subject: [PATCH 4/5] fix counter
---
src/Button/Button.features.stories.tsx | 8 ++++----
src/Button/ButtonBase.tsx | 4 +++-
src/Button/styles.ts | 3 ---
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/Button/Button.features.stories.tsx b/src/Button/Button.features.stories.tsx
index 532d166161f..36d3ee6bd1a 100644
--- a/src/Button/Button.features.stories.tsx
+++ b/src/Button/Button.features.stories.tsx
@@ -21,7 +21,7 @@ export const TrailingVisual = () => Trailing vi
export const TrailingCounter = () => {
const [count, setCount] = useState(0)
return (
- setCount(count + 1)} count={count}>
+ setCount(count + 1)} trailingVisualCount={count}>
Watch
)
@@ -50,13 +50,13 @@ export const InvisibleVariants = () => {
Button
-
+
Button
-
+
Button
-
+
Button
diff --git a/src/Button/ButtonBase.tsx b/src/Button/ButtonBase.tsx
index 947fe7e6803..84243010490 100644
--- a/src/Button/ButtonBase.tsx
+++ b/src/Button/ButtonBase.tsx
@@ -63,7 +63,9 @@ const ButtonBase = forwardRef(
ref={innerRef}
data-component={block ? 'block' : null}
data-size={size === 'small' || size === 'large' ? size : undefined}
- data-no-visuals={!LeadingVisual && !TrailingVisual && !TrailingAction ? true : undefined}
+ data-no-visuals={
+ !LeadingVisual && !TrailingVisual && !TrailingAction && !trailingVisualCount ? true : undefined
+ }
>
{LeadingVisual && (
diff --git a/src/Button/styles.ts b/src/Button/styles.ts
index 42e9b32a331..0d43a3a3683 100644
--- a/src/Button/styles.ts
+++ b/src/Button/styles.ts
@@ -127,9 +127,6 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
'&[data-no-visuals]': {
color: 'accent.fg',
},
- '&:has([data-component="ButtonCounter"])': {
- color: 'btn.text',
- },
},
}
return style[variant]
From 674e54d14ef3bd092d3eb86020dc02edb7d7ed24 Mon Sep 17 00:00:00 2001
From: langermank <18661030+langermank@users.noreply.github.com>
Date: Tue, 20 Dec 2022 11:53:55 -0800
Subject: [PATCH 5/5] snaps
---
src/__tests__/__snapshots__/Button.test.tsx.snap | 4 ----
src/__tests__/__snapshots__/TextInput.test.tsx.snap | 12 ------------
2 files changed, 16 deletions(-)
diff --git a/src/__tests__/__snapshots__/Button.test.tsx.snap b/src/__tests__/__snapshots__/Button.test.tsx.snap
index d81764ef5c2..814dd347e38 100644
--- a/src/__tests__/__snapshots__/Button.test.tsx.snap
+++ b/src/__tests__/__snapshots__/Button.test.tsx.snap
@@ -1608,10 +1608,6 @@ exports[`Button styles invisible button appropriately 1`] = `
color: accent.fg;
}
-.c0:has([data-component="ButtonCounter"]) {
- color: btn.text;
-}
-
@media (forced-colors:active) {
.c0:focus {
outline: solid 1px transparent;
diff --git a/src/__tests__/__snapshots__/TextInput.test.tsx.snap b/src/__tests__/__snapshots__/TextInput.test.tsx.snap
index 4b72e6ebeb5..b73523e31ab 100644
--- a/src/__tests__/__snapshots__/TextInput.test.tsx.snap
+++ b/src/__tests__/__snapshots__/TextInput.test.tsx.snap
@@ -1426,10 +1426,6 @@ exports[`TextInput renders trailingAction icon button 1`] = `
color: #0969da;
}
-.c4:has([data-component="ButtonCounter"]) {
- color: #24292f;
-}
-
.c4[data-component="IconButton"] {
width: var(--inner-action-size);
height: var(--inner-action-size);
@@ -2053,10 +2049,6 @@ exports[`TextInput renders trailingAction text button 1`] = `
color: #0969da;
}
-.c3:has([data-component="ButtonCounter"]) {
- color: #24292f;
-}
-
.c3[data-component="IconButton"] {
width: var(--inner-action-size);
height: var(--inner-action-size);
@@ -2441,10 +2433,6 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
color: #0969da;
}
-.c4:has([data-component="ButtonCounter"]) {
- color: #24292f;
-}
-
.c4[data-component="IconButton"] {
width: var(--inner-action-size);
height: var(--inner-action-size);