Skip to content

Commit b65d575

Browse files
committed
feat(chevron): add toTop button
1 parent 4fab378 commit b65d575

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useRoutes } from '@solidjs/router';
22
import { Footer } from './components/layout/footer';
33
import { Navigation } from './components/layout/navigation';
4+
import { Up } from './components/layout/up';
45
import { routes } from './routes';
56

67
export function App() {
@@ -10,9 +11,8 @@ export function App() {
1011
<div class='dark:bg-zinc-900 transition'>
1112
<div class='min-h-screen 2xl:container 2xl:mx-auto sm:py-6 sm:px-7 py-5 px-4'>
1213
<Navigation />
13-
1414
<Routes />
15-
15+
<Up></Up>
1616
<Footer />
1717
</div>
1818
</div>

src/components/docs/Navigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const NavigationDocs = ({ params, onSetPackage, onChoosePackage, folders,
2828

2929
return (
3030
<div
31-
class='sm:w-72 sm:max-h-[75vh] sm:overflow-y-scroll will-change-transform'
31+
class='sm:w-72 pb-10 will-change-transform'
3232
>
3333
<h1 class='text-primary font-bold text-xl font-ledger'>Documentation</h1>
3434

src/components/layout/up.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { FiChevronUp } from 'solid-icons/fi';
2+
import { createSignal } from 'solid-js';
3+
4+
export const Up = () => {
5+
const [scroll, setScroll] = createSignal(window.scrollY);
6+
7+
window.addEventListener(
8+
'scroll',
9+
() => {
10+
setScroll(window.scrollY);
11+
},
12+
true
13+
);
14+
15+
const toTheSky = () => {
16+
window.scrollTo({ top: 0, behavior: 'smooth' });
17+
history.pushState('', document.title, window.location.pathname + window.location.search);
18+
};
19+
const cl = 'fixed bottom-10 right-10 bg-primary rounded-full transition duration-500 transform';
20+
21+
return (
22+
<div class={`${cl} ${scroll() > 100 ? 'translate-y-0' : 'translate-y-24'}`}>
23+
<button class='p-3' onClick={toTheSky}>
24+
<FiChevronUp size={24} class='text-white'></FiChevronUp>
25+
</button>
26+
</div>
27+
);
28+
};

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Router } from '@solidjs/router';
33
import { render } from 'solid-js/web';
44
import { App } from './App';
55
import './assets/css/main.css';
6+
67
const Main = () => (
78
<MetaProvider>
89
<Title>JOSH | Home</Title>

src/pages/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ await josh.set("foo", "bar");\n\`\`\``;
8989
<div class='sm:w-1/2 sm:px-8 mt-8 sm:mt-0'>
9090
<div
9191
innerHTML={md.render(code)}
92-
class='bg-zinc-800 px-8 sm:px-0 text-white rounded-lg shadow-xl py-8 sm:px-10 text-sm sm:text-md xl:text-lg sm:py-10'
92+
class='bg-zinc-800 overflow-x-scroll px-8 sm:px-0 text-white rounded-lg shadow-xl py-8 sm:px-10 text-sm sm:text-md xl:text-lg sm:py-10'
9393
></div>
9494
<div></div>
9595
</div>

vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mdx from '@mdx-js/rollup';
22
import remarkGfm from 'remark-gfm';
33
import { defineConfig } from 'vite';
44
import solid from 'vite-plugin-solid';
5+
56
export default defineConfig({
67
build: {
78
target: 'ESNext',
@@ -16,7 +17,7 @@ export default defineConfig({
1617
}
1718
}
1819
},
19-
plugins: [mdx({ jsxImportSource: 'solid-jsx', remarkPlugins: [remarkGfm] }), solid()],
20+
plugins: [solid(), mdx({ jsxImportSource: 'solid-jsx', remarkPlugins: [remarkGfm] })],
2021
server: {
2122
strictPort: true
2223
}

0 commit comments

Comments
 (0)