-
Notifications
You must be signed in to change notification settings - Fork 0
create reusable btn #1
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
Open
s3713434
wants to merge
8
commits into
main
Choose a base branch
from
reusable-btn
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.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
59cadfa
create reusable btn
s3713434 fc1dbc4
finishing checkbox and change some var names :3
s3713434 a9ba741
damn forgot to delete the comments
s3713434 fe21595
change the format style
s3713434 398cc27
change the formatting style
s3713434 d0e68ec
change the formatting style
s3713434 02654af
Merge branch 'reusable-btn' of https://github.com/BeeQuantAI/probable…
s3713434 f679558
add missing tailwind class sorting plugin for prettier
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 hidden or 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,7 @@ | ||
| { | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "singleQuote": false, | ||
| "plugins": ["prettier-plugin-tailwindcss"], | ||
| "tailwindFunctions": ["clsx", "cn", "twmerge", "cva"] | ||
| } |
This file contains hidden or 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,12 +1,6 @@ | ||
| { | ||
| "tailwindCSS.experimental.classRegex": [ | ||
| [ | ||
| "cva\\(([^)]*)\\)", | ||
| "[\"'`]([^\"'`]*).*?[\"'`]" | ||
| ], | ||
| [ | ||
| "cx\\(([^)]*)\\)", | ||
| "(?:'|\"|`)([^']*)(?:'|\"|`)" | ||
| ] | ||
| ["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"], | ||
| ["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"] | ||
| ] | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,85 @@ | ||
| import { cva, type VariantProps } from "class-variance-authority"; | ||
| import React from "react"; | ||
| import { Label } from "./label"; | ||
|
|
||
| export interface CheckboxVariants | ||
| extends VariantProps<typeof checkboxVariants> {} | ||
|
|
||
| const checkboxVariants = cva( | ||
| "peer size-[18px] cursor-pointer appearance-none rounded border border-solid bg-transparent transition-all duration-500 focus:outline-none focus:ring-0 focus:ring-offset-0 group-hover:border-primary-300", | ||
| { | ||
| variants: { | ||
| variant: { | ||
| primary: "border-gary-layout-primary", | ||
| }, | ||
| size: { | ||
| small: "text-sm", | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| variant: "primary", | ||
| size: "small", | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| const svgVariants = cva( | ||
| [ | ||
| "size-4", | ||
| "cursor-pointer", | ||
| "opacity-0", | ||
| "peer-checked:opacity-100", | ||
| "transition-opacity", | ||
| "duration-300", | ||
| ], | ||
| { | ||
| variants: { | ||
| variant: { | ||
| primary: "primary-300", | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| variant: "primary", | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| type CheckboxProps = { | ||
| label?: React.ReactNode; | ||
| } & React.InputHTMLAttributes<HTMLInputElement> & | ||
| CheckboxVariants; | ||
|
|
||
| export function Checkbox({ | ||
| label, | ||
| variant, | ||
| color, | ||
| type = "checkbox", | ||
| ...props | ||
| }: CheckboxProps) { | ||
| return ( | ||
| <label className="group flex items-center gap-2"> | ||
| <div className="relative flex items-center"> | ||
| <input | ||
| className={checkboxVariants({ variant })} | ||
| type={type} | ||
| {...props} | ||
| /> | ||
| <svg | ||
| className={svgVariants({ variant })} | ||
| fill="#70bbfd" | ||
| viewBox="0 0 24 24" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| style={{ | ||
| position: "absolute", | ||
| top: "50%", | ||
| left: "50%", | ||
| transform: "translate(-50%, -50%)", | ||
| }} | ||
| > | ||
| <path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" /> | ||
| </svg> | ||
| </div> | ||
| {label && <Label>{label}</Label>} | ||
| </label> | ||
| ); | ||
| } |
This file contains hidden or 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 React from "react"; | ||
| import { cva, type VariantProps } from "class-variance-authority"; | ||
|
|
||
| const labelVariants = cva( | ||
| [ | ||
| "label", | ||
| "cursor-pointer", | ||
| "transition-all", | ||
| "duration-500", | ||
| "group-hover:text-primary-300", | ||
| ], | ||
| { | ||
| variants: { | ||
| color: { | ||
| white: "text-white", | ||
| }, | ||
| size: { | ||
| small: "text-sm", | ||
| medium: "text-base", | ||
| large: "text-lg", | ||
| }, | ||
| fontWeight: { | ||
| normal: "font-normal", | ||
| bold: "font-bold", | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| color: "white", | ||
| size: "small", | ||
| fontWeight: "normal", | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| type LabelProps = { | ||
| children: React.ReactNode; | ||
| } & VariantProps<typeof labelVariants>; | ||
|
|
||
| export const Label: React.FC<LabelProps> = ({ | ||
| children, | ||
| color, | ||
| size, | ||
| fontWeight, | ||
| }) => { | ||
| return ( | ||
| <span className={labelVariants({ color, size, fontWeight })}> | ||
| {children} | ||
| </span> | ||
| ); | ||
| }; |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.