-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { SimpleGrid } from '@mantine/core' | ||
import { UiAnchor, UiCard } from '@pubkey-ui/core' | ||
|
||
export function DemoFeatureAnchor() { | ||
return ( | ||
<UiCard title="Anchor"> | ||
<SimpleGrid cols={2}> | ||
<UiAnchor to="/">Anchor with To</UiAnchor> | ||
<UiAnchor href="https://google.com" target="_blank"> | ||
Anchor without To | ||
</UiAnchor> | ||
<UiAnchor>Anchor without To</UiAnchor> | ||
</SimpleGrid> | ||
</UiCard> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ui-anchor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Anchor, AnchorProps } from '@mantine/core' | ||
import { ReactNode } from 'react' | ||
import { Link } from 'react-router-dom' | ||
|
||
export interface UiAnchorProps extends AnchorProps { | ||
children: ReactNode | ||
href?: string | ||
to?: string | ||
target?: HTMLAnchorElement['target'] | ||
} | ||
|
||
export function UiAnchor({ children, href, target, to, ...props }: UiAnchorProps) { | ||
return to ? ( | ||
<Anchor component={Link} to={to} target={target} {...props}> | ||
{children} | ||
</Anchor> | ||
) : href ? ( | ||
<Anchor component="a" href={href} target={target} {...props}> | ||
{children} | ||
</Anchor> | ||
) : ( | ||
children | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...s/generators/src/generators/component/files/anchor/__prefixFileName__-anchor.tsx.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Anchor, AnchorProps } from '@mantine/core' | ||
import { ReactNode } from 'react' | ||
import { Link } from 'react-router-dom' | ||
|
||
export interface <%= prefix.className %>AnchorProps extends AnchorProps { | ||
children: ReactNode | ||
href?: string | ||
to?: string | ||
target?: HTMLAnchorElement['target'] | ||
} | ||
|
||
export function <%= prefix.className %>Anchor({ children, href, target, to, ...props }: <%= prefix.className %>AnchorProps) { | ||
return to ? ( | ||
<Anchor component={Link} to={to} target={target} {...props}> | ||
{children} | ||
</Anchor> | ||
) : href ? ( | ||
<Anchor component="a" href={href} target={target} {...props}> | ||
{children} | ||
</Anchor> | ||
) : ( | ||
children | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/generators/src/generators/component/files/anchor/index.ts.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './<%= prefixFileName %>-anchor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/generators/src/generators/feature/files/demo/demo-feature-anchor.tsx.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { SimpleGrid } from '@mantine/core' | ||
import { <%= prefix.className %>Anchor, <%= prefix.className %>Card } from '<%= uiImport %>' | ||
|
||
export function DemoFeatureAnchor() { | ||
return ( | ||
<<%= prefix.className %>Card title="Anchor"> | ||
<SimpleGrid cols={2}> | ||
<<%= prefix.className %>Anchor to="/">Anchor with To</<%= prefix.className %>Anchor> | ||
<<%= prefix.className %>Anchor href="https://google.com" target="_blank"> | ||
Anchor without To | ||
</<%= prefix.className %>Anchor> | ||
<<%= prefix.className %>Anchor>Anchor without To</<%= prefix.className %>Anchor> | ||
</SimpleGrid> | ||
</<%= prefix.className %>Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.