-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add button link as styles function, introduce tailwind-merge #593
Open
DTCurrie
wants to merge
2
commits into
main
Choose a base branch
from
add-button-link-maybe
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+10,329
−11,882
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,34 @@ | ||
/** | ||
* Link styled to look like a button. | ||
* | ||
* Currently, only the "ghost" variant is implemented. | ||
* | ||
* @function | ||
*/ | ||
|
||
import { twMerge, type ClassNameValue } from 'tailwind-merge'; | ||
|
||
export type ButtonLinkVariant = 'ghost' | 'dark'; | ||
|
||
export interface ButtonLinkAttributes { | ||
variant?: ButtonLinkVariant; | ||
extraClasses?: ClassNameValue; | ||
} | ||
|
||
const BUTTON_LINK_CLASSES = | ||
'flex h-7.5 items-center gap-1.5 whitespace-nowrap px-3 py-1.5 text-xs'; | ||
|
||
const BUTTON_LINK_VARIANT_CLASSES = { | ||
ghost: 'text-default hover:bg-ghost-light active:bg-ghost-medium', | ||
dark: 'border border-gray-9 bg-gray-9 text-white hover:border-black hover:bg-black active:bg-[#000]', | ||
} as const; | ||
|
||
export const buttonLinkStyles = ({ | ||
variant = 'ghost', | ||
extraClasses = '', | ||
}: ButtonLinkAttributes) => | ||
twMerge( | ||
BUTTON_LINK_CLASSES, | ||
BUTTON_LINK_VARIANT_CLASSES[variant], | ||
extraClasses | ||
); |
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 |
---|---|---|
@@ -1,54 +1,55 @@ | ||
<script lang="ts"> | ||
import { uniqueId } from 'lodash-es'; | ||
import { | ||
provideNotify, | ||
useNotify, | ||
provideToast, | ||
ToastVariant, | ||
Badge, | ||
Banner, | ||
Breadcrumbs, | ||
Button, | ||
IconButton, | ||
buttonLinkStyles, | ||
CodeSnippet, | ||
ContextMenu, | ||
ContextMenuItem, | ||
ContextMenuSeparator, | ||
FloatingMenu, | ||
Icon, | ||
Label, | ||
Banner, | ||
IconButton, | ||
Input, | ||
Label, | ||
Modal, | ||
Multiselect, | ||
NotificationContainer, | ||
NumericInput, | ||
Pill, | ||
Switch, | ||
Progress, | ||
Radio, | ||
TabsBar, | ||
Tab, | ||
Tooltip, | ||
TooltipContainer, | ||
TooltipTarget, | ||
TooltipText, | ||
TextInput, | ||
NumericInput, | ||
RangeInput, | ||
RestrictedTextInput, | ||
SearchableSelect, | ||
Select, | ||
SliderInput, | ||
VectorInput, | ||
Switch, | ||
Tab, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHeaderCell, | ||
TableHeader, | ||
TableHeaderCell, | ||
TableRow, | ||
TabsBar, | ||
TextInput, | ||
ToastBanner, | ||
ToastContainer, | ||
ToastVariant, | ||
ToggleButtons, | ||
Select, | ||
SearchableSelect, | ||
Multiselect, | ||
NotificationContainer, | ||
provideNotify, | ||
provideToast, | ||
useNotify, | ||
Modal, | ||
CodeSnippet, | ||
RangeInput, | ||
Progress, | ||
Tooltip, | ||
TooltipContainer, | ||
TooltipTarget, | ||
TooltipText, | ||
VectorInput, | ||
} from '$lib'; | ||
import { uniqueId } from 'lodash-es'; | ||
|
||
provideNotify(); | ||
|
||
|
@@ -193,7 +194,6 @@ console.log(\`The FizzBuzz sequence for n = 15 is:\`); | |
console.log(sequence); // Outputs: ["1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"]`.trim(); | ||
|
||
const goSnippet = ` | ||
import "fmt" | ||
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. The linter actually hates this, will fix later. |
||
|
||
// FizzBuzz | ||
// | ||
|
@@ -465,6 +465,44 @@ const onHoverDelayMsInput = (event: Event) => { | |
|
||
<NotificationContainer /> | ||
|
||
<div class="container mx-auto my-4 flex flex-col gap-8 p-4"> | ||
<h2 class="h-2">New stuff!</h2> | ||
|
||
<div class="flex items-center gap-2"> | ||
<p class="text-xs">Check out this cool thing:</p> | ||
<a | ||
href="https://design.viam.com" | ||
target="_blank" | ||
class={buttonLinkStyles({})} | ||
> | ||
My button link | ||
</a> | ||
</div> | ||
|
||
<div class="flex items-center gap-2"> | ||
<p class="text-xs">Check out this cool thing with an icon:</p> | ||
<a | ||
href="https://design.viam.com" | ||
target="_blank" | ||
class={buttonLinkStyles({ variant: 'dark' })} | ||
> | ||
<Icon name="link" /> | ||
My button link | ||
</a> | ||
</div> | ||
|
||
<div class="flex items-center gap-2"> | ||
<p class="text-xs">Check out this pink thing:</p> | ||
<a | ||
href="https://design.viam.com" | ||
target="_blank" | ||
class={buttonLinkStyles({ extraClasses: 'text-pink-500' })} | ||
> | ||
My button link | ||
</a> | ||
</div> | ||
</div> | ||
|
||
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. I will create a better example if we decide to go this way. |
||
<div class="container mx-auto my-4 flex flex-col gap-8 p-4"> | ||
<!-- Badge --> | ||
<h1 class="text-2xl">Badge</h1> | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just some import sorting.