Skip to content

Commit 95f62d0

Browse files
committed
Convert all components to Astro
1 parent 25b7242 commit 95f62d0

31 files changed

+398
-547
lines changed

README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,19 @@ If you are using them in an Astro layout file, then the import would look like t
2121
import '/node_modules/@interledger/docs-design-system/src/styles/green-theme.css';
2222
```
2323

24-
We also have a number of documentation-specific helper components that can be imported and used where necessary.
25-
26-
- [CodeBlock](#codeblock-component)
27-
- [Disclosure](#disclosure-component)
28-
- [Hidden](#hidden-component)
29-
- [LargeImg](#largeimg-component)
30-
- [LinkOut](#linkout-component)
31-
- [MermaidWrapper](#mermaidwrapper-component)
32-
- [StylishHeader](#stylishheader-component)
33-
- [Tooltip](#tooltip-component)
34-
35-
For the shared components, if you are using both `CodeBlock` and `Disclosure` on the same page, you can import them both like so:
24+
We also have a number of documentation-specific helper components that can be imported and used where necessary. For these shared components, if you are using both `CodeBlock` and `Disclosure` on the same page, you can import them both like so:
3625

3726
```jsx
3827
import { CodeBlock, Disclosure } from "@interledger/docs-design-system";
3928
```
4029

4130
For more information about importing things in Javascript, please refer to [import on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).
4231

43-
All the above components are documented at our [documentation style guide](https://interledger.tech).
32+
The available shared components are documented at our [documentation style guide](https://interledger.tech).
4433

4534
## Contributing
4635

47-
As this is a shared library, it is a dependency for other projects, specifically all Interledger documentation websites. A good way to check who is using this library is via GitHub search: https://github.com/search?q=%22%40interledger%2Fdocs-design-system%22%3A+&type=code.
36+
As this is a shared library, it is a dependency for other projects, specifically all Interledger documentation websites. A good way to check who is using this library is via GitHub search: https://github.com/search?q=%22%40interledger%2Fdocs-design-system%22%3A+path%3Apackage.json&type=code.
4837

4938
Our theme does override a number of Starlight defaults, therefore it is inevitable that if the Starlight internals are modified as they continue to release new features, we will have to make the corresponding updates to this library as well, to make sure nothing breaks. The documentation style guide is a good target to determine if the proposed changes you want to make to the library work correctly or not.
5039

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@interledger/docs-design-system",
3-
"version": "0.0.14",
3+
"version": "0.1.0",
44
"type": "module",
55
"description": "Shared styles and components used across all Interledger Starlight documentation sites",
66
"exports": {
@@ -18,8 +18,5 @@
1818
"repository": {
1919
"type": "git",
2020
"url": "https://github.com/interledger/docs-design-system"
21-
},
22-
"dependencies": {
23-
"react": "^18.2.0"
2421
}
2522
}

src/components/CodeBlock.astro

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
const { title } = Astro.props;
3+
---
4+
<div class="codeblock">
5+
<p>{title}</p>
6+
<slot />
7+
</div>
8+
9+
<style>
10+
div {
11+
position: relative;
12+
}
13+
14+
.codeblock.codeblock.codeblock :global(pre) {
15+
border-top-right-radius: 0;
16+
border-top-left-radius: 0;
17+
margin-top: 0;
18+
}
19+
20+
p {
21+
margin-top: var(--space-s);
22+
border-top-right-radius: var(--border-radius);
23+
border-top-left-radius: var(--border-radius);
24+
font-size: var(--step--1);
25+
font-weight: bold;
26+
padding: var(--space-2xs) var(--space-xs);
27+
background-color: var(--astro-code-color-background);
28+
border-bottom: 1px solid var(--sl-color-gray-5);
29+
}
30+
</style>

src/components/CodeBlock/CodeBlock.jsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/components/CodeBlock/CodeBlock.module.css

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/components/CodeBlock/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
.toggle {
1+
---
2+
const { toggleText } = Astro.props;
3+
const uuid = crypto.randomUUID();
4+
---
5+
<button
6+
data-disclosure-button
7+
type="button"
8+
aria-expanded="false"
9+
aria-controls={uuid}
10+
>
11+
{toggleText}
12+
</button>
13+
<div class="wrapper" id={uuid}>
14+
<div class="content"><slot /></div>
15+
</div>
16+
17+
<style>
18+
button {
219
background-color: initial;
320
border: 0;
421
display: flex;
@@ -9,33 +26,52 @@
926
transition: color 200ms ease-out;
1027
}
1128

12-
.toggle:hover,
13-
.toggle:focus {
29+
button:hover,
30+
button:focus {
1431
color: var(--sl-color-text-accent);
1532
}
1633

17-
.toggle[aria-expanded='false']::after {
34+
button[aria-expanded="false"]::after {
1835
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 12 8" width="12" height="8"><path fill="currentColor" d="M11 1.17a1 1 0 0 0-1.41 0L6 4.71 2.46 1.17a1 1 0 0 0-1.41 1.42l4.24 4.24a1.002 1.002 0 0 0 1.42 0L11 2.59a1.003 1.003 0 0 0 0-1.42Z"/></svg>');
1936
position: relative;
2037
bottom: 2px;
2138
}
2239

23-
.toggle[aria-expanded='true']::after {
40+
button[aria-expanded="true"]::after {
2441
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 12 8" width="12" height="8"><path fill="currentColor" d="M11 5.41 6.71 1.17a1 1 0 0 0-1.42 0L1.05 5.41a1 1 0 1 0 1.41 1.42L6 3.29l3.54 3.54a1 1 0 0 0 1.41 0A1.001 1.001 0 0 0 11 5.41Z"/></svg>');
2542
position: relative;
2643
bottom: 2px;
2744
}
2845

46+
:global([data-theme="dark"]) button::after {
47+
filter: invert(1);
48+
}
49+
2950
.wrapper {
3051
display: grid;
3152
grid-template-rows: 0fr;
3253
transition: grid-template-rows 0.3s ease-out;
3354
}
3455

35-
.wrapper.expanded {
56+
button[aria-expanded="true"] + .wrapper {
3657
grid-template-rows: 1fr;
3758
}
3859

3960
.content {
4061
overflow: hidden;
4162
}
63+
</style>
64+
65+
<script>
66+
const buttons = document.querySelectorAll('[data-disclosure-button]');
67+
buttons.forEach((button) => {
68+
button.addEventListener('click', function() {
69+
if (this.getAttribute('aria-expanded') === 'true') {
70+
this.setAttribute('aria-expanded', 'false');
71+
}
72+
else {
73+
this.setAttribute('aria-expanded', 'true');
74+
}
75+
});
76+
});
77+
</script>

src/components/Disclosure/Disclosure.jsx

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/components/Disclosure/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/components/Hidden.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
---
3+
<div style={{ display: "none" }}><slot /></div>

0 commit comments

Comments
 (0)