Skip to content

Commit fa1dac8

Browse files
committed
feat: scroll feature completed
1 parent 7252a2d commit fa1dac8

File tree

17 files changed

+110
-44
lines changed

17 files changed

+110
-44
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@radix-ui/react-icons": "1.3.0",
13-
"brouther": "4.3.3",
13+
"brouther": "4.4.0",
1414
"prism-react-renderer": "1.3.5",
1515
"react": "18.2.0",
1616
"react-dom": "18.2.0",

docs/pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/components/anchor.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
type Props<C extends React.ElementType> = {
2-
as?: C;
3-
children: React.ReactNode;
4-
} & React.ComponentPropsWithoutRef<C>;
1+
import React from "react";
2+
import { Link, LinkProps } from "brouther";
53

6-
export const Anchor = <AS extends React.ElementType = "a">({ as, ...props }: Props<AS>) => {
7-
const Component = as || "a";
4+
export const Anchor = <TPath extends string>(props: LinkProps<TPath>) => {
85
return (
9-
<Component
6+
<Link
107
{...props}
118
className={`text-transparent m-0 p-0 font-extrabold tracking-wide bg-clip-text bg-gradient-to-r from-indigo-400 to-violet-500 inline-block border-b border-transparent link:border-b-indigo-400 transition-colors duration-300 ${
129
props.className ?? ""

docs/src/components/document-page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const DocumentPage = (props: React.PropsWithChildren<Props>) => {
4949
items: [
5050
{ title: "<Brouther />", link: router.links.brouther },
5151
{ title: "<Link />", link: router.links.linkComponent },
52+
{ title: "<Scroll />", link: router.links.scroll },
5253
],
5354
},
5455
{
@@ -97,7 +98,7 @@ export const DocumentPage = (props: React.PropsWithChildren<Props>) => {
9798
{x.items.map((y) => (
9899
<li key={y.title} className="my-1 ml-4">
99100
{y.link === currentPage ? (
100-
<Anchor as={Link} href={y.link}>
101+
<Anchor href={y.link}>
101102
{y.title}
102103
</Anchor>
103104
) : (

docs/src/components/footer.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React from "react";
22
import { Anchor } from "./anchor";
33
import { GitHubLogoIcon } from "@radix-ui/react-icons";
4-
import { Link } from "brouther";
54

65
export const Footer = () => {
76
return (
87
<footer className="w-full bg-slate-950 py-8 text-white text-center mt-auto">
98
<section className="flex justify-center items-center">
10-
<Anchor href="https://github.com/g4rcez/brouther" target="_blank" as={Link}>
9+
<Anchor href="https://github.com/g4rcez/brouther" target="_blank">
1110
<GitHubLogoIcon className="text-white inline-block mr-1 mb-0.5" />
1211
Github
1312
</Anchor>

docs/src/pages/basic-setup.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { DocumentPage } from "../components/document-page";
22
import { Code } from "../components/code";
33
import { SubTitle } from "../components/subtitle";
44
import { Anchor } from "../components/anchor";
5-
import { Link } from "brouther";
65
import { router } from "../router";
76

87
const code = `import { createMappedRouter, usePage } from "brouther";
@@ -47,14 +46,10 @@ export default function BasicSetup() {
4746
</p>
4847
<ul className="my-4">
4948
<li className="my-2">
50-
<Anchor href={router.links.createRouter} as={Link}>
51-
createRouter
52-
</Anchor>
49+
<Anchor href={router.links.createRouter}>createRouter</Anchor>
5350
</li>
5451
<li className="my-2">
55-
<Anchor href={router.links.createMappedRouter} as={Link}>
56-
createMappedRouter
57-
</Anchor>
52+
<Anchor href={router.links.createMappedRouter}>createMappedRouter</Anchor>
5853
</li>
5954
</ul>
6055
<p>You will see more about API's at this document, but first you need to focus on routers.</p>

docs/src/pages/brouther.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function BroutherPage() {
6969
<InlineCode>{"<Brouther />"}</InlineCode> it's the entrypoint for your config. This is the library{" "}
7070
<Anchor href="https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context">context provider</Anchor> and using
7171
this enable all brouther features, like{" "}
72-
<Anchor as={Link} href={router.links.linkComponent}>
72+
<Anchor href={router.links.linkComponent}>
7373
Link
7474
</Anchor>{" "}
7575
component and hooks. You just need to provide the <InlineCode>router.config</InlineCode> from your createRouter or createMappedRouter.

docs/src/pages/form/form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function FormPage() {
1818
<DocumentPage title="Form">
1919
<p>
2020
This component make you able to use the{" "}
21-
<Anchor as={Link} href={router.links.actions}>
21+
<Anchor href={router.links.actions}>
2222
actions
2323
</Anchor>{" "}
2424
and the special behaviour to submit forms using JSON notation, inspired by{" "}

docs/src/pages/form/tricks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export default function TricksPage() {
5050
<DocumentPage title="Tricks and Tips">
5151
<p>
5252
When you using{" "}
53-
<Anchor as={Link} href={router.links.actions}>
53+
<Anchor href={router.links.actions}>
5454
actions
5555
</Anchor>{" "}
5656
and{" "}
57-
<Anchor as={Link} href={router.links.loaders}>
57+
<Anchor href={router.links.loaders}>
5858
loaders
5959
</Anchor>
6060
, you may need to apply a code splitting properly. To help you, brouther has some utility functions. These utility functions help you

docs/src/pages/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const features = [
2121
<Fragment>Utility to create URLs</Fragment>,
2222
<Fragment>Simple API, less effort to remember things</Fragment>,
2323
<Fragment>
24-
Lightweight - <Anchor href="https://bundlephobia.com/package/brouther@latest">Less than 8Kb</Anchor>
24+
Scroll control and restoration
2525
</Fragment>,
2626
];
2727

@@ -50,7 +50,7 @@ export default function IndexPage() {
5050
<Card title="Next Level DX" Icon={MagicWandIcon}>
5151
<p>
5252
Using a fully connected type system, you can track all of your{" "}
53-
<Anchor href={router.links.aliases} as={Link}>
53+
<Anchor href={router.links.aliases} >
5454
routes using aliases
5555
</Anchor>
5656
. You will never need to write strings in your code, just use the alias and see the magic of your new router
@@ -60,7 +60,7 @@ export default function IndexPage() {
6060
<p>
6161
You need to change basename? Easy. You have feature flags feature on your app? Brouther can take care. You need full control
6262
of your routes? Just use{" "}
63-
<Anchor href={router.links.hooks} as={Link}>
63+
<Anchor href={router.links.hooks} >
6464
Brouther hooks
6565
</Anchor>{" "}
6666
and you will have full power over pages, errors and URL state.
@@ -69,11 +69,11 @@ export default function IndexPage() {
6969
<Card title="Want more?" Icon={MagnifyingGlassIcon}>
7070
<p>
7171
Just this? You can check all features and benefits of Brouther. You can read at{" "}
72-
<Anchor href={router.links.hooks} as={Link}>
72+
<Anchor href={router.links.hooks} >
7373
Brouther features
7474
</Anchor>{" "}
7575
or you can do your own app using Brouther. Don't know how? Check on{" "}
76-
<Anchor href={router.links.examples} as={Link}>
76+
<Anchor href={router.links.examples} >
7777
Examples section
7878
</Anchor>
7979
.

0 commit comments

Comments
 (0)