Skip to content

Commit 5a0ace3

Browse files
committed
[feature] Footer
1 parent 5b88ce3 commit 5a0ace3

8 files changed

Lines changed: 62 additions & 1 deletion

File tree

package/src/components/App/index.css.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,24 @@ export const mainHasSideNav = style(
7878
paddingLeft: `calc(${dimensions.sideNavWidth} + ${dimensions.padding})`,
7979
}),
8080
);
81+
82+
export const mainHasFooter = style({
83+
paddingBottom: `calc(${dimensions.footerHeight} + ${dimensions.padding})`,
84+
});
85+
86+
export const footer = style({
87+
display: 'flex',
88+
justifyContent: 'right',
89+
alignItems: 'center',
90+
gap: dimensions.padding,
91+
padding: dimensions.padding,
92+
position: 'fixed',
93+
bottom: 0,
94+
left: 0,
95+
right: 0,
96+
height: dimensions.footerHeight,
97+
backgroundColor: colors.backgroundHaze,
98+
borderTop: colors.border,
99+
boxShadow: colors.shadow,
100+
backdropFilter: 'blur(8px)',
101+
});

package/src/components/App/index.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import {Button} from '../Button/index.tsx';
2323
import {
2424
app,
2525
appLayout,
26+
footer,
2627
header,
2728
main,
29+
mainHasFooter,
2830
mainHasSideNav,
2931
sideNav,
3032
sideNavButton,
@@ -83,6 +85,11 @@ export const App = (props: {
8385
* the application.
8486
*/
8587
readonly main?: ComponentType | ReactNode;
88+
/**
89+
* An optional component, element, or string which renders the footer of
90+
* the application.
91+
*/
92+
readonly footer?: ComponentType | ReactNode;
8693
/**
8794
* An extra CSS class name for the component.
8895
*/
@@ -104,6 +111,7 @@ const Layout = ({
104111
topNavRight: topNavRightComponentOrNode,
105112
sideNav: sideNavComponentOrNode,
106113
main: mainComponentOrNode,
114+
footer: footerComponentOrNode,
107115
className,
108116
}: Parameters<typeof App>[0]) => {
109117
const sessionStoreIsReady = useSessionStoreIsReady();
@@ -124,8 +132,10 @@ const Layout = ({
124132
topNavRightComponentOrNode,
125133
sideNavComponentOrNode,
126134
mainComponentOrNode,
135+
footerComponentOrNode,
127136
].some((componentOrNode) => componentOrNode);
128137
const hasSideNav = sideNavComponentOrNode != null;
138+
const hasFooter = footerComponentOrNode != null;
129139

130140
return sessionStoreIsReady && routeStoreIsReady && localStoreIsReady ? (
131141
<div
@@ -169,9 +179,20 @@ const Layout = ({
169179
</nav>
170180
) : null}
171181
</header>
172-
<main className={classNames(main, hasSideNav && mainHasSideNav)}>
182+
<main
183+
className={classNames(
184+
main,
185+
hasSideNav && mainHasSideNav,
186+
hasFooter && mainHasFooter,
187+
)}
188+
>
173189
{renderComponentOrNode(mainComponentOrNode)}
174190
</main>
191+
{hasFooter ? (
192+
<footer className={footer}>
193+
{renderComponentOrNode(footerComponentOrNode)}
194+
</footer>
195+
) : null}
175196
</>
176197
) : null}
177198
</div>

package/src/css/dimensions.css.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const classAndObject = createTheme({
88
radius: fallbackVar('var(--tinyWidgets-radius)', '0.5rem'),
99
sideNavWidth: fallbackVar('var(--tinyWidgets-sideNavWidth)', '20rem'),
1010
topNavHeight: fallbackVar('var(--tinyWidgets-topNavHeight)', '4rem'),
11+
footerHeight: fallbackVar('var(--tinyWidgets-footerHeight)', '2rem'),
1112
});
1213
export const dimensionsClass = classAndObject[0];
1314

@@ -24,6 +25,7 @@ export const dimensionsClass = classAndObject[0];
2425
* - `radius`
2526
* - `sideNavWidth`
2627
* - `topNavHeight`
28+
* - `footerHeight`
2729
*
2830
* You can use these variables directly in React components that take style
2931
* attributes, like this:

site/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
useSetRouteCallback,
99
} from 'tinywidgets';
1010
import {article, title} from './App.css';
11+
import {Footer} from './components/Footer.tsx';
1112
import {SideNav} from './components/SideNav.tsx';
1213
import {Home} from './pages/Home.tsx';
1314
import {ROUTES} from './pages/index.ts';
@@ -24,6 +25,7 @@ export const App = () => (
2425
}
2526
sideNav={SideNav}
2627
main={Main}
28+
footer={Footer}
2729
/>
2830
);
2931

site/src/components/Footer.css.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {style} from '@vanilla-extract/css';
2+
import {colors} from 'tinywidgets/css';
3+
4+
export const footer = style({
5+
color: colors.foregroundDim,
6+
fontSize: '0.8rem',
7+
});

site/src/components/Footer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import {footer} from './Footer.css';
2+
3+
export const Footer = () => <div className={footer}>TinyWidgets © 2024-</div>;

site/src/pages/Configuration.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const Configuration = () => {
3737
3838
--tinyWidgets-sideNavWidth: 20rem;
3939
--tinyWidgets-topNavHeight: 4rem;
40+
--tinyWidgets-topNavHeight: 2rem;
4041
}
4142
`}
4243
/>

site/src/pages/_api.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ of the application.</p>
4545
main:<><p>An optional component, element, or string which renders the main part of
4646
the application.</p>
4747
</>,
48+
footer:<><p>An optional component, element, or string which renders the footer of
49+
the application.</p>
50+
</>,
4851
className:<><p>An extra CSS class name for the component.</p>
4952
</>,
5053
}}
@@ -949,6 +952,7 @@ application.</p>
949952
<li><code>radius</code></li>
950953
<li><code>sideNavWidth</code></li>
951954
<li><code>topNavHeight</code></li>
955+
<li><code>footerHeight</code></li>
952956
</ul>
953957
<p>You can use these variables directly in React components that take style
954958
attributes, like this:</p>

0 commit comments

Comments
 (0)