astroidjs 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ ---
2
+ // `<Credit>`—the agency credit from `config.credit`, for the site's footer.
3
+ // Renders nothing when the config has no `credit`, so it's safe to leave in a
4
+ // footer permanently.
5
+ //
6
+ // The mark is a CSS mask filled with `currentColor`, not an `<img>`. An SVG
7
+ // loaded through `<img>` renders in its own document and can't see the page's
8
+ // text color, so it would stay whatever color it was drawn in on every theme.
9
+ // As a mask, only its shape counts and the fill follows the theme. It's
10
+ // `aria-hidden` because the name beside it already says who it is, so a screen
11
+ // reader reads the name once.
12
+ //
13
+ // The styles are scoped here rather than written as Tailwind utilities: a site
14
+ // may not scan node_modules, and the credit has to look the same either way.
15
+ import type { AstroidConfig } from "astroidjs";
16
+
17
+ interface Props {
18
+ config: AstroidConfig;
19
+ class?: string;
20
+ }
21
+
22
+ const { config, class: className } = Astro.props;
23
+ const credit = config.credit;
24
+ // `defineAstroid` limits `logo` to a root-relative path or an https URL, and
25
+ // JSON quoting keeps a space or parenthesis in the path from ending the `url()`.
26
+ const markStyle = credit?.logo ? `--astroid-credit-mark:url(${JSON.stringify(credit.logo)})` : "";
27
+ ---
28
+
29
+ {
30
+ credit && (
31
+ <p class:list={["astroid-credit", className]}>
32
+ <a href={credit.href} rel={credit.rel}>
33
+ {credit.logo && <span class="astroid-credit__mark" aria-hidden="true" style={markStyle} />}
34
+ <span>
35
+ {credit.label ?? "Site by"} {credit.name}
36
+ </span>
37
+ </a>
38
+ </p>
39
+ )
40
+ }
41
+
42
+ <style>
43
+ .astroid-credit {
44
+ margin: 0;
45
+ font-size: 0.75rem;
46
+ line-height: 1.5;
47
+ }
48
+ /* Low contrast, not illegible: 70% of the theme's text color stays above
49
+ WCAG AA on daisyUI's light and dark base colors. */
50
+ .astroid-credit a {
51
+ display: inline-flex;
52
+ align-items: center;
53
+ gap: 0.4em;
54
+ color: inherit;
55
+ opacity: 0.7;
56
+ text-decoration: none;
57
+ }
58
+ .astroid-credit a:hover,
59
+ .astroid-credit a:focus-visible {
60
+ opacity: 1;
61
+ text-decoration: underline;
62
+ }
63
+ .astroid-credit__mark {
64
+ flex: none;
65
+ width: 1.25em;
66
+ height: 1.25em;
67
+ background-color: currentColor;
68
+ mask: var(--astroid-credit-mark) center / contain no-repeat;
69
+ }
70
+ </style>