-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(components): refactor components and remove tailwind prefix #7
Merged
devjoaov
merged 8 commits into
main
from
joao/click-565-update-bleu-ui-tailwind-configuration
Jan 23, 2024
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
91ec24c
fix: remove prefix from tailwind config
devjoaov 0915d72
chore(component): create rails app context
devjoaov d25d8e0
chore(component): add boolean field to datatable
devjoaov 5cc36bb
chore(component): use rails context to get csrftoken on form
devjoaov ef25969
chore(component): add radio group component
devjoaov ed380b2
chore(component): truncate text column on swr table
devjoaov 1ff1b4d
chore(Tooltip): remove bleu-ui- prefix from tooltip
ribeirojose 4454a5e
fix: datatable use icon for boolean field
devjoaov 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
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 @@ | ||
import React, { createContext, useContext } from "react"; | ||
|
||
export const RailsAppContext = createContext(""); | ||
|
||
export const RailsAppProvider = ({ children, csrfToken }) => ( | ||
<RailsAppContext.Provider value={csrfToken}> | ||
{children} | ||
</RailsAppContext.Provider> | ||
); | ||
|
||
export const useRailsApp = () => useContext(RailsAppContext); |
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 @@ | ||
export * from "./context"; |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
} from "react-hook-form"; | ||
import { cn } from "@/lib/utils"; | ||
import { Label } from "@/components/ui/Label"; | ||
import { useRailsApp } from "@/components/RailsApp/context"; | ||
|
||
type FormFieldContextValue< | ||
TFieldValues extends FieldValues = FieldValues, | ||
|
@@ -25,17 +26,15 @@ const Form = ({ | |
action, | ||
method, | ||
encType = "application/x-www-form-urlencoded", | ||
csrfToken, | ||
...props | ||
}: React.ComponentProps<typeof FormProvider> & { | ||
action: string; | ||
children: React.ReactNode; | ||
className?: string; | ||
csrfToken?: string; | ||
encType?: string; | ||
method?: "post" | "get"; | ||
}) => { | ||
// const csrfToken = ReactOnRails.authenticityToken(); | ||
const csrfToken = useRailsApp(); | ||
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.
|
||
|
||
if (!csrfToken) { | ||
throw new Error("Missing authenticity_token"); | ||
|
@@ -55,7 +54,6 @@ const Form = ({ | |
</FormProvider> | ||
); | ||
}; | ||
|
||
const FormFieldContext = React.createContext<FormFieldContextValue>( | ||
{} as FormFieldContextValue | ||
); | ||
|
@@ -112,15 +110,12 @@ const FormItemContext = React.createContext<FormItemContextValue>( | |
const FormItem = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => { | ||
const id = React.useMemo(() => ({ id: React.useId() }), []); | ||
|
||
return ( | ||
<FormItemContext.Provider value={id}> | ||
<div ref={ref} className={cn("space-y-2", className)} {...props} /> | ||
</FormItemContext.Provider> | ||
); | ||
}); | ||
>(({ className, ...props }, ref) => ( | ||
// eslint-disable-next-line react/jsx-no-constructed-context-values | ||
<FormItemContext.Provider value={{ id: React.useId() }}> | ||
<div ref={ref} className={cn("space-y-2", className)} {...props} /> | ||
</FormItemContext.Provider> | ||
)); | ||
FormItem.displayName = "FormItem"; | ||
|
||
const FormLabel = React.forwardRef< | ||
|
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.
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.
😬 this is a bit odd, right? I'd even use emojis ❌ and ✅ instead of True and False strings. I think only technical users would digest that 😅