Skip to content

Commit 1dcc152

Browse files
Merge pull request #27 from IATI/inline-icons
Inline icons
2 parents 4b8feb1 + cd247bf commit 1dcc152

File tree

10 files changed

+50
-37
lines changed

10 files changed

+50
-37
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"files": [
1616
"src/scss/**/*.scss",
17+
"src/assets/**/*",
1718
"dist/css/**/*.css",
1819
"dist/js/**/*.js"
1920
],

src/scss/components/brand-background/_brand-background.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
@use "../../tokens/screens" as *;
33

44
.iati-brand-background {
5-
$var-background-image: --background-image;
6-
#{$var-background-image}: url("/src/assets/svg/marque-white.svg");
7-
85
background-color: $color-teal-90;
96
display: grid;
107
@media (min-width: $screen-md) {
118
&:after {
129
content: "";
1310
grid-area: 1/-1;
14-
background-image: var($var-background-image);
11+
background-image: url("@assets/svg/marque-white.svg");
1512
background-repeat: no-repeat;
1613
background-position: right 2rem top;
1714
background-size: 32.3rem auto;

src/scss/components/button/_button.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
background-color: $color-teal-80;
2323
}
2424

25-
&__icon {
26-
width: 1rem;
25+
&__icon,
26+
& .iati-icon {
27+
height: 1rem;
2728
}
2829

2930
&--light {

src/scss/components/button/button.stories.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Meta, StoryObj } from "@storybook/web-components";
2-
import iconInfoUrl from "../../../assets/svg/icon-info.svg";
32

43
import { html } from "lit";
54

@@ -38,7 +37,7 @@ export const WithIcon: Story = {
3837
render: () => html`
3938
<button class="iati-button iati-button--light">
4039
<span>Info</span>
41-
<img class="iati-button__icon" src="${iconInfoUrl}" alt="" />
40+
<i class="iati-icon iati-icon--info"></i>
4241
</button>
4342
`,
4443
};

src/scss/components/country-switcher/_country-switcher.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
font-family: $font-stack-heading;
2424
color: $color-grey-90;
2525
font-weight: 600;
26-
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none'%3E%3Cpath stroke='%23121212' stroke-linecap='square' stroke-width='1.3' d='M10 19c4.9706 0 9-4.0294 9-9 0-4.97056-4.0294-9-9-9-4.97056 0-9 4.02944-9 9 0 4.9706 4.02944 9 9 9Z'/%3E%3Cpath stroke='%23121212' stroke-linecap='round' stroke-linejoin='bevel' stroke-width='1.3' d='M9.99984 18.991C12.3938 16.8114 13.5908 13.8144 13.5908 10c0-3.81433-1.197-6.81133-3.59096-8.99097-2.394 2.17964-3.591 5.17664-3.591 8.99097 0 3.8144 1.197 6.8114 3.591 8.991Z'/%3E%3Cpath stroke='%23121212' stroke-linecap='round' stroke-width='1.3' d='M1.44991 7.29993H18.5499M1.44991 12.6999H18.5499'/%3E%3C/svg%3E");
26+
background-image: url("@assets/svg/icon-globe.svg");
2727
background-repeat: no-repeat;
2828
background-position: 0.5em center;
2929
}

src/scss/components/footer/footer.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { html } from "lit";
44
import { CountrySwitcher } from "../../components/country-switcher/country-switcher.stories";
55
import {
66
Facebook,
7-
Linkedin,
7+
LinkedIn,
88
X,
99
Youtube,
1010
} from "../../components/icon/icon.stories";
@@ -67,7 +67,7 @@ export const Footer: Story = {
6767
href="https://www.linkedin.com/company/international-aid-transparency-initiative/"
6868
aria-label="LinkedIn"
6969
>
70-
${Linkedin.render?.call({ ...args })}
70+
${LinkedIn.render?.call({ ...args })}
7171
</a>
7272
<a href="https://x.com/IATI_aid" aria-label="X">
7373
${X.render?.call({ ...args })}

src/scss/components/header/header.stories.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { Meta, StoryObj } from "@storybook/web-components";
22
import { html } from "lit";
3-
import iconInfoUrl from "../../../assets/svg/icon-info.svg";
4-
import iconSearchUrl from "../../../assets/svg/icon-search.svg";
53
import logoColourUrl from "../../../assets/svg/logo-colour.svg";
64
import { CountrySwitcher } from "../../components/country-switcher/country-switcher.stories";
75
import { Open as MenuToggle } from "../../components/menu-toggle/menu-toggle.stories";
@@ -62,11 +60,11 @@ export const Header: Story = {
6260
${CountrySwitcher.render?.call({ ...args })}
6361
<button class="iati-button iati-button--light hide--mobile-nav">
6462
<span>Help Docs</span>
65-
<img class="iati-button__icon" src="${iconInfoUrl}" alt="" />
63+
<i class="iati-icon iati-icon--info"></i>
6664
</button>
6765
<button class="iati-button iati-button--light">
6866
<span>Search</span>
69-
<img class="iati-button__icon" src="${iconSearchUrl}" alt="" />
67+
<i class="iati-icon iati-icon--search"></i>
7068
</button>
7169
${MenuToggle.render?.call({ ...args })}
7270
</div>

src/scss/components/icon/_icon.scss

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,32 @@
66
background-position: center;
77
background-size: 100%;
88

9+
&--info {
10+
background-image: url("@assets/svg/icon-info.svg");
11+
}
12+
13+
&--search {
14+
background-image: url("@assets/svg/icon-search.svg");
15+
}
16+
17+
&--globe {
18+
background-image: url("@assets/svg/icon-globe.svg");
19+
}
20+
921
&--youtube {
10-
background-image: url("/src/assets/svg/youtube-logo.svg");
22+
background-image: url("@assets/svg/youtube-logo.svg");
1123
aspect-ratio: 1.2 / 1;
1224
}
1325

1426
&--x {
15-
background-image: url("/src/assets/svg/x-logo.svg");
27+
background-image: url("@assets/svg/x-logo.svg");
1628
}
1729

1830
&--linkedin {
19-
background-image: url("/src/assets/svg/linkedin-logo.svg");
31+
background-image: url("@assets/svg/linkedin-logo.svg");
2032
}
2133

2234
&--facebook {
23-
background-image: url("/src/assets/svg/facebook-logo.svg");
35+
background-image: url("@assets/svg/facebook-logo.svg");
2436
}
2537
}

src/scss/components/icon/icon.stories.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@ import { html } from "lit";
33

44
const meta: Meta = {
55
title: "Components/Icon",
6-
parameters: {
7-
backgrounds: {
8-
default: "dark",
9-
},
10-
},
116
};
127

138
export default meta;
149
type Story = StoryObj;
1510

16-
export const Youtube: Story = {
17-
render: () => html`<i class="iati-icon iati-icon--youtube"></i>`,
18-
};
19-
20-
export const X: Story = {
21-
render: () => html`<i class="iati-icon iati-icon--x"></i>`,
22-
};
23-
24-
export const Linkedin: Story = {
25-
render: () => html`<i class="iati-icon iati-icon--linkedin"></i>`,
11+
const createStory = (variant: string, background = "light") => {
12+
const classes = `iati-icon iati-icon--${variant}`;
13+
return {
14+
parameters: {
15+
backgrounds: {
16+
default: background,
17+
},
18+
},
19+
render: () => html`<i class=${classes}></i>`,
20+
};
2621
};
2722

28-
export const Facebook: Story = {
29-
render: () => html`<i class="iati-icon iati-icon--facebook"></i>`,
30-
};
23+
export const Info: Story = createStory("info");
24+
export const Search: Story = createStory("search");
25+
export const Globe: Story = createStory("globe");
26+
export const Youtube: Story = createStory("youtube", "dark");
27+
export const X: Story = createStory("x", "dark");
28+
export const LinkedIn: Story = createStory("linkedin", "dark");
29+
export const Facebook: Story = createStory("facebook", "dark");

vite.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from "path";
22
import { NodePackageImporter } from "sass";
3+
import { fileURLToPath } from "url";
34
import { defineConfig } from "vite";
45

56
export default defineConfig({
@@ -32,4 +33,9 @@ export default defineConfig({
3233
},
3334
},
3435
},
36+
resolve: {
37+
alias: {
38+
"@assets": fileURLToPath(new URL("./src/assets", import.meta.url)),
39+
},
40+
},
3541
});

0 commit comments

Comments
 (0)