Skip to content

Commit 694ffd0

Browse files
committed
Add styled JSX banner to layout
1 parent 62f2221 commit 694ffd0

3 files changed

Lines changed: 114 additions & 5 deletions

File tree

src/utils/jsx/banner.tsx

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { css, cx } from 'hono/css';
2+
3+
import theme from '../theme.ts';
4+
5+
const styles = {
6+
banner: css`
7+
color: ${theme.text.inverted};
8+
display: flex;
9+
flex-direction: row;
10+
flex-wrap: wrap;
11+
align-items: center;
12+
position: relative;
13+
isolation: isolate;
14+
padding-top: ${theme.spacing(1)};
15+
padding-bottom: ${theme.spacing(1)};
16+
17+
&::before {
18+
content: '';
19+
position: absolute;
20+
width: 100vw;
21+
left: 50%;
22+
transform: translateX(-50%);
23+
background: ${theme.background.brand};
24+
top: 0;
25+
bottom: 0;
26+
z-index: -1;
27+
}
28+
`,
29+
intro: css`
30+
border-right: ${theme.spacing(0.25)} solid currentColor;
31+
margin: 0 ${theme.spacing(1)} 0 0;
32+
padding: 0 ${theme.spacing(1)} 0 0;
33+
font-size: ${theme.font.large.size};
34+
font-weight: ${theme.font.large.weight};
35+
`,
36+
text: css`
37+
margin: 0;
38+
`,
39+
link: css`
40+
color: currentColor;
41+
text-decoration: underline;
42+
43+
&:hover {
44+
text-decoration: none;
45+
}
46+
`,
47+
};
48+
49+
/**
50+
* Standard cdnjs HTML layout for the page pre-footer banner.
51+
*
52+
* @param props Component props.
53+
* @param props.class Optional additional class name(s) to apply to the banner.
54+
*/
55+
export default ({ class: className }: { class?: string | Promise<string> }) => (
56+
<div class={cx(styles.banner, className)}>
57+
<p class={styles.intro}>Help support cdnjs</p>
58+
<p class={styles.text}>
59+
You can{' '}
60+
<a
61+
href="https://github.com/cdnjs/packages/issues"
62+
rel="noopener"
63+
class={styles.link}
64+
>
65+
contribute on GitHub
66+
</a>{' '}
67+
to get involved with cdnjs! Or, help fund the maintenance of cdnjs
68+
via{' '}
69+
<a
70+
href="https://github.com/cdnjs/packages?sponsor"
71+
rel="noopener"
72+
class={styles.link}
73+
>
74+
GitHub Sponsors
75+
</a>
76+
,{' '}
77+
<a
78+
href="https://opencollective.com/cdnjs"
79+
rel="noopener"
80+
class={styles.link}
81+
>
82+
Open Collective
83+
</a>
84+
, or{' '}
85+
<a
86+
href="https://www.patreon.com/cdnjs"
87+
rel="noopener"
88+
class={styles.link}
89+
>
90+
Patreon
91+
</a>
92+
.
93+
</p>
94+
</div>
95+
);

src/utils/jsx/layout.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import type { Child } from 'hono/jsx';
33

44
import theme from '../theme.ts';
55

6+
import Banner from './banner.tsx';
67
import Footer from './footer.tsx';
78

89
const styles = {
910
body: css`
10-
display: flex;
11-
flex-direction: column;
12-
min-height: 100vh;
1311
font-size: ${theme.font.body.size};
1412
font-weight: ${theme.font.body.weight};
1513
overflow-x: hidden;
@@ -19,7 +17,12 @@ const styles = {
1917
color: ${theme.text.primary};
2018
`,
2119
main: css`
22-
flex: 1;
20+
display: flex;
21+
flex-direction: column;
22+
min-height: 100vh;
23+
`,
24+
content: css`
25+
flex-grow: 1;
2326
`,
2427
container: css`
2528
margin: 0 auto;
@@ -57,7 +60,12 @@ export default ({ children }: { children?: Child }) => (
5760
/>
5861
</head>
5962
<body class={cx(styles.body, styles.background)}>
60-
<main class={cx(styles.main, styles.container)}>{children}</main>
63+
<main class={styles.main}>
64+
<div class={cx(styles.content, styles.container)}>
65+
{children}
66+
</div>
67+
<Banner class={styles.container} />
68+
</main>
6169
<Footer class={styles.container} />
6270
<script
6371
defer

src/utils/theme.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ const breakpoint = (value: number) =>
44
export default {
55
text: {
66
primary: '#ebebeb',
7+
inverted: '#141515',
78
secondary: '#a6a6a6',
89
brand: '#d9643a',
910
},
1011
background: {
1112
body: '#454647',
13+
brand: '#d9643a',
1214
footer: '#242525',
1315
},
1416
spacing: (value: number) => `${value * 8}px`,
1517
breakpoints: {
1618
medium: breakpoint(96),
1719
},
1820
font: {
21+
large: {
22+
size: '1.25rem',
23+
weight: 400,
24+
},
1925
body: {
2026
size: '1rem',
2127
weight: 400,

0 commit comments

Comments
 (0)