-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add <Header /> and <Avatar /> components (#26)
* chore(studio): initial code for header component * refactor(studio): conditionally showing underline on link hover state * chore(studio): add basic header * added header dropdown menu && several fixes and improvements * fix(app): resolved pckg deps * feat(ui): add <Avatar /> component && various tweeks * feat(studio): add menu header component * refactor(ui): change <Avatar /> root styles && bumped pckg
- Loading branch information
Showing
17 changed files
with
1,658 additions
and
1,722 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
apps/studio/src/components/common/Header/Header.module.css
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,12 @@ | ||
.blui-root { | ||
@apply bg-mauve-50 border-b border-mauve-600 py-4; | ||
} | ||
|
||
.blui-separator { | ||
@apply h-8 w-[1px] bg-gray-600 transform-gpu ml-7 mr-6; | ||
} | ||
|
||
.blui-page--text { | ||
@apply font-medium; | ||
/* @apply bg-clip-text !text-transparent bg-gradient-btn-active !decoration-crimson-700 !decoration-2; */ | ||
} |
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,50 @@ | ||
import Image from "next/image"; | ||
import Logo from "~/assets/images/biolnk.png"; | ||
import Menu from "./Menu"; | ||
import Link from "../Link"; | ||
import { BaseIcon, Container, Text, Copy, Button } from "@biolnk/ui"; | ||
import { ctl } from "@biolnk/utils"; | ||
|
||
import Styles from "./Header.module.css"; | ||
|
||
const Header = () => { | ||
const rootClass = ctl(` | ||
${Styles["blui-root"]} | ||
`); | ||
|
||
return ( | ||
<header className={rootClass}> | ||
<Container className="flex items-center justify-between h-full"> | ||
<div className="flex items-center"> | ||
<Image | ||
src={Logo} | ||
height={36} | ||
width={22} | ||
placeholder="blur" | ||
alt="Biolnk.me branding" | ||
title="Biolnk.me branding" | ||
/> | ||
<div className={`${Styles["blui-separator"]} rotate-[30deg]`} /> | ||
|
||
<Link url="/chirila" variant="basic"> | ||
<Text as="span" className={Styles["blui-page--text"]}> | ||
biolnk.me/chirila | ||
</Text> | ||
</Link> | ||
<Button variant="text" size="xs" title="Copy to clipboard"> | ||
<BaseIcon | ||
aria-label="Copy to clipboard" | ||
icon={Copy} | ||
size="lg" | ||
stroke="hsl(336 73.7% 53.5%)" | ||
/> | ||
</Button> | ||
</div> | ||
|
||
<Menu /> | ||
</Container> | ||
</header> | ||
); | ||
}; | ||
|
||
export default Header; |
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,39 @@ | ||
import Link from "../Link"; | ||
import { Plus, Dropdown, Avatar } from "@biolnk/ui"; | ||
import { useSupabase } from "~/lib/supabase"; | ||
import { Routes } from "~/data/enums/routes"; | ||
|
||
const Menu = () => { | ||
const { signOut } = useSupabase(); | ||
|
||
return ( | ||
<Dropdown | ||
trigger={ | ||
<button type="button"> | ||
<Avatar alt="chirila" /> | ||
</button> | ||
} | ||
> | ||
<Dropdown.Group> | ||
{/* @ts-ignore */} | ||
<Dropdown.ListItem as={Link} url={Routes.DASHBOARD}> | ||
Dashboard | ||
</Dropdown.ListItem> | ||
</Dropdown.Group> | ||
|
||
<Dropdown.Group> | ||
<Dropdown.ListItem rightIcon={Plus}>Add Link</Dropdown.ListItem> | ||
{/* @ts-ignore */} | ||
<Dropdown.ListItem as={Link} url={Routes.ACCOUNT}> | ||
Settings | ||
</Dropdown.ListItem> | ||
</Dropdown.Group> | ||
|
||
<Dropdown.Group> | ||
<Dropdown.ListItem onClick={signOut}>Log out</Dropdown.ListItem> | ||
</Dropdown.Group> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default Menu; |
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ export enum Routes { | |
SIGNIN = "/signin", | ||
SIGNUP = "/signup", | ||
DASHBOARD = "/", | ||
ACCOUNT = "/account", | ||
} |
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,11 @@ | ||
.blui-root { | ||
@apply inline-flex items-center justify-center overflow-hidden select-none rounded-full bg-mauve-200 w-11 h-11 border border-mauve-400 shadow-sm; | ||
} | ||
|
||
.blui-image { | ||
@apply w-full h-full object-cover rounded-full; | ||
} | ||
|
||
.blui-fallback { | ||
@apply w-full h-full flex items-center justify-center text-plum-800 font-medium; | ||
} |
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,60 @@ | ||
import React, { forwardRef, useCallback } from "react"; | ||
import * as AvatarPrimitive from "@radix-ui/react-avatar"; | ||
import { ctl } from "@biolnk/utils"; | ||
|
||
import Styles from "./Avatar.module.css"; | ||
|
||
const DEFAULT_TAG = "span"; | ||
|
||
export interface AvatarOwnProps | ||
extends React.ComponentPropsWithRef<typeof DEFAULT_TAG> { | ||
src?: string; | ||
alt: string; | ||
fallback?: string; | ||
delay?: number; | ||
} | ||
|
||
const Avatar = forwardRef<HTMLSpanElement, AvatarOwnProps>( | ||
({ src, alt, fallback, delay = 600, className, ...otherProps }, ref) => { | ||
const getFallback = useCallback((value: string) => { | ||
const fallbackValue = []; | ||
const splitValue = value.split(" "); | ||
const secondWord = splitValue[1]; | ||
|
||
fallbackValue.push(value.charAt(0)); | ||
|
||
if (secondWord && secondWord.length > 0) { | ||
fallbackValue.push(secondWord.charAt(0)); | ||
} else { | ||
fallbackValue.push(value.charAt(1)); | ||
} | ||
|
||
return fallbackValue.join("").toUpperCase(); | ||
}, []); | ||
|
||
const defaultFallback = fallback ?? getFallback(alt); | ||
|
||
const rootClass = ctl(` | ||
${Styles["blui-root"]} | ||
${className} | ||
`); | ||
|
||
return ( | ||
<AvatarPrimitive.Root ref={ref} className={rootClass} {...otherProps}> | ||
<AvatarPrimitive.Image | ||
className={Styles["blui-image"]} | ||
src={src} | ||
alt={alt} | ||
/> | ||
<AvatarPrimitive.Fallback | ||
delayMs={delay} | ||
className={Styles["blui-fallback"]} | ||
> | ||
{defaultFallback} | ||
</AvatarPrimitive.Fallback> | ||
</AvatarPrimitive.Root> | ||
); | ||
} | ||
); | ||
|
||
export { Avatar }; |
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
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.
b226a6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: