Skip to content

Commit d9adfb7

Browse files
committed
Add button to copy icon URLs
1 parent fea6e1d commit d9adfb7

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.storybook/components/Icons.module.css

+14-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
.wrapper {
4646
position: relative;
4747
width: 7.5rem;
48-
margin-top: var(--cui-spacings-giga);
49-
margin-bottom: var(--cui-spacings-giga);
48+
padding-bottom: var(--cui-spacings-tera);
49+
margin-top: var(--cui-spacings-mega);
5050
text-align: center;
5151
}
5252

@@ -94,3 +94,15 @@
9494
left: 50%;
9595
transform: translate(-50%, -50%) rotate(-30deg);
9696
}
97+
98+
.copy {
99+
position: absolute;
100+
right: 50%;
101+
bottom: 0;
102+
display: none;
103+
transform: translateX(50%);
104+
}
105+
106+
.wrapper:hover .copy {
107+
display: block;
108+
}

.storybook/components/Icons.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { clsx } from '../../packages/circuit-ui/styles/clsx.js';
3535
import { utilClasses } from '../../packages/circuit-ui/styles/utility.js';
3636
import { slugify } from '../slugify.js';
3737
import classes from './Icons.module.css';
38+
import { IconButton } from '@sumup-oss/circuit-ui';
3839

3940
function groupBy(
4041
icons: IconsManifest['icons'],
@@ -77,7 +78,7 @@ export function Icons() {
7778

7879
const handleChange =
7980
(setState: Dispatch<SetStateAction<string>>) =>
80-
(event: ChangeEvent<any>) => {
81+
(event: ChangeEvent<HTMLInputElement | HTMLSelectElement>) => {
8182
setState(event.target.value);
8283
};
8384

@@ -160,6 +161,10 @@ export function Icons() {
160161
icon.name,
161162
) as keyof typeof iconComponents;
162163
const Icon = iconComponents[componentName] as IconComponentType;
164+
const copyIconURL = () => {
165+
const iconURL = `https://circuit.sumup.com/icons/v2/${icon.name}_${icon.size}.svg`;
166+
navigator.clipboard.writeText(iconURL);
167+
};
163168
return (
164169
<div key={id} className={classes.wrapper}>
165170
<div
@@ -180,9 +185,7 @@ export function Icons() {
180185
</div>
181186
<span id={id} className={classes.label}>
182187
{componentName}
183-
{size === 'all' && (
184-
<span className={classes.size}>{icon.size}</span>
185-
)}
188+
<span className={classes.size}>{icon.size}</span>
186189
</span>
187190
{icon.deprecation && (
188191
<Tooltip
@@ -200,6 +203,15 @@ export function Icons() {
200203
)}
201204
/>
202205
)}
206+
<IconButton
207+
variant="tertiary"
208+
size="s"
209+
icon={iconComponents.Link}
210+
className={classes.copy}
211+
onClick={copyIconURL}
212+
>
213+
Copy URL
214+
</IconButton>
203215
</div>
204216
);
205217
})}

0 commit comments

Comments
 (0)