-
-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small buttons update #1608
base: main
Are you sure you want to change the base?
Small buttons update #1608
Changes from 4 commits
a414e96
cb0ccf2
ece3ef3
c7c293d
7dc84ce
bb2862d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,30 @@ | ||
--- | ||
import SHA from './SHA.astro'; | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
|
||
interface Props { | ||
color?: 'orange' | 'green' | 'lightblue' | 'semidarkblue'; | ||
size?: 'sm' | 'lg' | 'lg-full' | 'sm-mobfull'; | ||
import SHA from '@/components/ui/SHA.astro'; | ||
import Link from '@/components/util/Link.astro'; | ||
|
||
export const buttonVariants = cva( | ||
'font-bold text-white drop-shadow transition-colors rounded-full text-center', | ||
{ | ||
variants: { | ||
color: { | ||
orange: 'bg-nix-orange hover:bg-nix-orange-hover', | ||
lightblue: 'bg-nix-blue-light hover:bg-nix-blue-light-hover', | ||
semidarkblue: 'bg-nix-blue-dark hover:bg-nix-blue-dark-hover', | ||
green: 'bg-nix-green hover:bg-nix-green-hover', | ||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my testing I couldn't really tell how the hover state applied, am I missing something or is it just to subtile? I'd guess the mentioned colors may need to be defined first. :D |
||
}, | ||
size: { | ||
sm: 'px-10 py-2.5', | ||
'sm-mobfull': 'px-8 py-2.5 md:w-auto w-full', | ||
lg: 'px-10 py-2.5 md:px-14 md:py-4 w-full md:w-auto', | ||
'lg-full': 'px-10 py-4 block', | ||
}, | ||
}, | ||
}, | ||
); | ||
|
||
interface Props extends VariantProps<typeof buttonVariants> { | ||
href?: string | null; | ||
type?: 'button' | 'submit' | 'reset'; | ||
classList?: string[]; | ||
|
@@ -13,20 +34,6 @@ interface Props { | |
label?: string; | ||
} | ||
|
||
const colorMap = { | ||
orange: 'bg-nix-orange', | ||
lightblue: 'bg-nix-blue-light', | ||
semidarkblue: 'bg-nix-blue-dark', | ||
green: 'bg-nix-green', | ||
}; | ||
|
||
const sizeMap = { | ||
sm: 'px-10 py-2.5 rounded-3xl text-center', | ||
'sm-mobfull': 'px-8 py-2.5 rounded-3xl md:w-auto w-full text-center', | ||
lg: 'px-10 py-2.5 md:px-14 md:py-4 rounded-full md:rounded-2xl text-center w-full md:w-auto', | ||
'lg-full': 'text-center py-4 block rounded-2xl', | ||
}; | ||
|
||
const { | ||
color = 'orange', | ||
size = 'sm', | ||
|
@@ -38,27 +45,29 @@ const { | |
shaText = '', | ||
label, | ||
} = Astro.props; | ||
|
||
const localClassList = `${colorMap[color]} font-bold ${sizeMap[size]} text-white drop-shadow`; | ||
--- | ||
|
||
{ | ||
href ? ( | ||
<> | ||
<a | ||
<Link | ||
href={href} | ||
class:list={['!text-white !no-underline', localClassList, classList]} | ||
class:list={[ | ||
'!text-white !no-underline', | ||
buttonVariants({ color, size }), | ||
classList, | ||
]} | ||
> | ||
{label || <slot />} | ||
</a> | ||
</Link> | ||
{shaHref && ( | ||
<SHA href={shaHref} classList={shaClassList}> | ||
{shaText} | ||
</SHA> | ||
)} | ||
</> | ||
) : ( | ||
<button type={type} class={localClassList}> | ||
<button type={type} class={buttonVariants({ color, size })}> | ||
<slot /> | ||
</button> | ||
) | ||
|
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.
Fully rounded corners are an interesting design change, though I'm not really a fan of it, this comes especially into play when seeing how buttons behave inside cards as seen on the learn site. The fully rounded corners do not really seem to fit into the more boxy card shape, while the old design aligns more with its parent design and at least in my opinion looks more coherent.