Skip to content

Commit b090955

Browse files
committed
docs: import styles globally rather than inline in a file (all-contributors#933)
docs(styles): apply stylesheets globally docs: document custom styles
1 parent 5e8f1a1 commit b090955

File tree

5 files changed

+33
-41
lines changed

5 files changed

+33
-41
lines changed

astro.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export default defineConfig({
1717
starlight({
1818
customCss: [
1919
'./src/styles/global.css',
20-
'./src/fonts/font-face.css'],
20+
'./src/fonts/font-face.css',
21+
],
2122
title: '',
2223
logo: {
2324
src: './src/assets/logo-full.svg',

src/content/docs/index.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ hero:
2121
attrs:
2222
rel: me
2323
---
24-
25-
import "../../styles/allcontributors.scss";
2624
import { LinkCard, CardGrid } from "@astrojs/starlight/components";
2725
import { Picture } from "astro:assets";
2826
import { LinkButton } from '@astrojs/starlight/components';

src/content/docs/project/development.mdx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ vite: {
4747
},
4848
```
4949
50-
5150
## Adding Images to the Docs
5251
5352
We use the `<Picture>` utility to add images to our documentation. This utility supports a web compression feature that will automatically convert images to formats like webp and avif upon rendering.
5453
55-
To use the Picture utility,
54+
To use the `Picture` utility:
5655
5756
1. First import the utility at the top of the `.mdx` file like this
5857
```markdown
@@ -81,9 +80,27 @@ In the config file code snippet above, you can see that Tailwind CSS is included
8180
8281
Tailwind is also a required dependency for Starlight, so it is already set up and ready to use.
8382
83+
We have also vendored a Google Font which is then applied in the global stylesheet.
84+
The global stylesheet is located at `src/styles/global.css`. The configuration to add
85+
these styles globally is found in the `astro.config.mjs` file.
86+
87+
```js
88+
integrations: [
89+
starlight({
90+
customCss: [
91+
'./src/styles/global.css',
92+
'./src/fonts/font-face.css',
93+
],
94+
```
95+
8496
## Fonts
8597
86-
The all contributors documentation site uses the Google Font **Poppins** as a base font. For convenience and web page loading speed, we have vendored the font have vendored the font in the assets/fonts directory for quicker loading and rendering times.
98+
The all contributors documentation site uses the Google Font **Poppins** as a
99+
base font. For convenience and web page loading speed, we have vendored the font
100+
have vendored the font in the `assets/fonts` directory for quicker loading and
101+
rendering times. The font is applied globally to headers in the `global.css` file.
102+
103+
If we want to customize other font properties, we can do so in the `global.css` file.
87104
88105
<Aside type="note" title="Need Help?">
89106
If you have questions or want to contribute to the documentation, check out our [GitHub repository](https://github.com/all-contributors/all-contributors).

src/styles/allcontributors.scss

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +0,0 @@
1-
body {
2-
font-family: 'Poppins', sans-serif;
3-
}
4-
5-
.add-contribs {
6-
width: 100vw;
7-
margin-left: 50%;
8-
transform: translateX(-50%);
9-
padding: 0 0;
10-
text-align: center;
11-
margin-bottom: 0;
12-
13-
14-
p {
15-
font-size: 20px;
16-
color: #2d2298;
17-
max-width: 800px;
18-
line-height: 1.5;
19-
margin: 0 auto 32px;
20-
}
21-
}
22-
23-
.add-contribs.purple {
24-
background: #f2f2fb;
25-
margin-top: 0;
26-
margin-bottom: 0;
27-
padding: 8rem 0;
28-
}
29-
30-
31-
// buttons
32-
.ac-btn-primary {
33-
@apply no-underline inline-block bg-[#2d2298] text-white font-sans font-semibold rounded-xl px-8 py-4 shadow-lg transition-all duration-200 hover:bg-[#1a155c] hover:scale-105 text-center min-w-[180px];
34-
}

src/styles/global.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22

33
@import '@astrojs/starlight-tailwind';
44
@import 'tailwindcss/theme.css' layer(theme);
5-
@import 'tailwindcss/utilities.css' layer(utilities);
5+
@import 'tailwindcss/utilities.css' layer(utilities);
6+
7+
8+
body {
9+
font-family: 'Poppins', sans-serif;
10+
}
11+
12+
// buttons
13+
.ac-btn-primary {
14+
@apply no-underline inline-block bg-[#2d2298] text-white font-sans font-semibold rounded-xl px-8 py-4 shadow-lg transition-all duration-200 hover:bg-[#1a155c] hover:scale-105 text-center min-w-[180px];
15+
}

0 commit comments

Comments
 (0)