Skip to content

Commit

Permalink
🎨 xsmall variant for CopyButton (#1994)
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh authored May 22, 2023
1 parent b7a9733 commit 444e905
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .changeset/twelve-carrots-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@navikt/ds-css": patch
"@navikt/ds-react": patch
---

:tada: CopyButton har nå en `xsmall`-variant

- Kan nå lettere brukes i tabeller
22 changes: 22 additions & 0 deletions @navikt/core/css/copybutton.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
min-height: 2rem;
}

.navds-copybutton--xsmall {
--__ac-copybutton-padding: var(--a-spacing-05) var(--a-spacing-2);

min-height: 1.5rem;
}

.navds-copybutton--icon-only {
--__ac-copybutton-padding: var(--a-spacing-3);
}
Expand All @@ -35,6 +41,14 @@
--__ac-copybutton-padding: var(--a-spacing-1);
}

.navds-copybutton--xsmall.navds-copybutton--icon-only {
--__ac-copybutton-padding: var(--a-spacing-05);
}

.navds-copybutton--xsmall .navds-copybutton__icon {
font-size: 1.25rem;
}

.navds-copybutton__icon {
font-size: 1.5rem;
display: flex;
Expand All @@ -45,6 +59,10 @@
margin: 0;
}

:where(.navds-copybutton--small, .navds-copybutton--xsmall):where(:not(:only-child)) {
margin: -2px;
}

.navds-copybutton:focus-visible {
outline: none;
box-shadow: var(--a-shadow-focus);
Expand Down Expand Up @@ -108,6 +126,10 @@
gap: var(--a-spacing-2);
}

.navds-copybutton--xsmall > .navds-copybutton__content {
gap: var(--a-spacing-1);
}

.navds-copybutton--active > .navds-copybutton__content {
animation: var(--ac-copybutton-animation, akselCopyButtonAnimation 0.4s linear);
}
Expand Down
3 changes: 2 additions & 1 deletion @navikt/core/react/src/copybutton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export interface CopyButtonProps
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
/**
* @default "medium"
* xsmall should only be used in tables/
*/
size?: "medium" | "small";
size?: "medium" | "small" | "xsmall";
/**
* @default "neutral"
*/
Expand Down
34 changes: 33 additions & 1 deletion @navikt/core/react/src/copybutton/copy-button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
size: {
defaultValue: "medium",
control: { type: "radio" },
options: ["small", "medium"],
options: ["small", "medium", "xsmall"],
},
variant: {
defaultValue: undefined,
Expand Down Expand Up @@ -85,6 +85,22 @@ export const Sizes = {
text="Kopier"
/>
</div>
<div className="rowgap">
<CopyButton size="xsmall" copyText="3.14" variant="action" />
<CopyButton size="xsmall" copyText="3.14" variant="neutral" />
<CopyButton
size="xsmall"
copyText="3.14"
variant="action"
text="Kopier"
/>
<CopyButton
size="xsmall"
copyText="3.14"
variant="neutral"
text="Kopier"
/>
</div>
</div>
),
};
Expand All @@ -107,6 +123,14 @@ export const Texts = {
activeText="Kopierte XYZ"
/>
</div>
<div>
<CopyButton
copyText="3.14"
size="xsmall"
text="Kopier XYZ"
activeText="Kopierte XYZ"
/>
</div>
</div>
),
};
Expand All @@ -129,6 +153,14 @@ export const Icons = {
activeIcon={<ThumbUpIcon title="Kopiert" />}
/>
</div>
<div>
<CopyButton
copyText="3.14"
size="xsmall"
icon={<LinkIcon title="Kopier" />}
activeIcon={<ThumbUpIcon title="Kopiert" />}
/>
</div>
</div>
),
};
Expand Down

0 comments on commit 444e905

Please sign in to comment.