diff --git a/src/components/Atoms/Link/Link.tsx b/src/components/Atoms/Link/Link.tsx index 29d8c4e..172ed7f 100644 --- a/src/components/Atoms/Link/Link.tsx +++ b/src/components/Atoms/Link/Link.tsx @@ -48,6 +48,7 @@ export function Link< className?: string; rel?: string; target?: string; + title?: string; } = LinkHTMLAttributes >({ children, as, ...props }: TLink): JSX.Element { const Tag = as || 'a'; diff --git a/src/components/Molecules/Button/Button.tsx b/src/components/Molecules/Button/Button.tsx index 0a10923..4cababc 100644 --- a/src/components/Molecules/Button/Button.tsx +++ b/src/components/Molecules/Button/Button.tsx @@ -88,6 +88,7 @@ export function Button< T extends { className?: string; type?: 'button' | 'submit' | 'reset'; + title?: string; } = ButtonHTMLAttributes >({ children, as, colorScheme = 'violet', size = 'M', icon = 'mumble', ...props }: TButton): JSX.Element { const Tag = as || 'button'; diff --git a/src/components/Molecules/InteractionButton/InteractionButton.tsx b/src/components/Molecules/InteractionButton/InteractionButton.tsx index a75ea65..6635e91 100644 --- a/src/components/Molecules/InteractionButton/InteractionButton.tsx +++ b/src/components/Molecules/InteractionButton/InteractionButton.tsx @@ -87,6 +87,7 @@ export function InteractionButton< T extends { className?: string; type?: 'button' | 'submit' | 'reset'; + title?: string; } = ButtonHTMLAttributes >({ as, colorScheme, buttonText, iconName, isActive = false, ...props }: TInteractionButton): JSX.Element { const Tag = as || 'button'; diff --git a/src/components/Molecules/Navi/Navi.stories.tsx b/src/components/Molecules/Navi/Navi.stories.tsx index e0a545e..68ed86d 100644 --- a/src/components/Molecules/Navi/Navi.stories.tsx +++ b/src/components/Molecules/Navi/Navi.stories.tsx @@ -17,13 +17,31 @@ export const Navi = Template.bind({}); Navi.args = { children: ( <> - + { + window.location.href = '/'; + }} + icon="settings" + title="Settings" + > Settings - + { + window.location.href = '/'; + }} + icon="settings" + title="Settings" + > Settings - + { + window.location.href = '/'; + }} + icon="settings" + title="Settings" + > Settings diff --git a/src/components/Molecules/Navi/NaviButton.stories.tsx b/src/components/Molecules/Navi/NaviButton.stories.tsx index bba95f7..02ab752 100644 --- a/src/components/Molecules/Navi/NaviButton.stories.tsx +++ b/src/components/Molecules/Navi/NaviButton.stories.tsx @@ -20,7 +20,6 @@ const Template: ComponentStory = (args): JSX.Element => = { /** * Choose a HTML tag as Navigation Button: */ - as: TNaviButtonTag; + as?: FC; /** * Icon name from the Icon library */ @@ -27,20 +19,7 @@ type TNaviButton = { * React Node children: Buttontext */ children: ReactNode; -}; -/** - * If the button is rendered as button tag, use this one - */ -type HTMLButtonProps = TNaviButton & - HTMLAttributes & { as: 'button' } & ButtonHTMLAttributes; -/** - * LinkButtonProps: if the button is rendered as a tag, use this - */ -type LinkButtonProps = TNaviButton & HTMLAttributes & { as: 'a' } & AnchorHTMLAttributes; -/** - * generic: LinkButton or HTML Button props - */ -type NaviButtonProps = LinkButtonProps | HTMLButtonProps; +} & Omit; /* * Styles @@ -54,8 +33,19 @@ const style = [ 'bg-violet-600 hover:bg-violet-700', 'group', ]; +export function NaviButton< + T extends { + className?: string; + type?: 'button' | 'submit' | 'reset'; + title?: string; + } = ButtonHTMLAttributes +>({ children, as, icon, ...props }: TNaviButton): JSX.Element { + const Tag = as || 'button'; + + if (Tag === 'button') { + props.type = 'button'; + } -export const NaviButton: FC = ({ as: Tag = 'a', children, icon, ...props }) => { if (Children.count(children) === 1 && typeof children === 'string') { children = ( diff --git a/src/templates/Snippets/Header/Header.tsx b/src/templates/Snippets/Header/Header.tsx index 752058a..97800ec 100644 --- a/src/templates/Snippets/Header/Header.tsx +++ b/src/templates/Snippets/Header/Header.tsx @@ -90,7 +90,13 @@ export const Header: FC = ({ user }) => {