-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:paranext/paranext-core into fix-cha…
…pter-range-selector
- Loading branch information
Showing
21 changed files
with
3,228 additions
and
2,465 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
64 changes: 64 additions & 0 deletions
64
lib/platform-bible-react/src/components/shadcn-ui/toggle-group.tsx
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,64 @@ | ||
import React from 'react'; | ||
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group'; | ||
import { type VariantProps } from 'class-variance-authority'; | ||
|
||
import { cn } from '@/utils/shadcn-ui.util'; | ||
import { toggleVariants } from '@/components/shadcn-ui/toggle'; | ||
|
||
const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({ | ||
size: 'default', | ||
variant: 'default', | ||
}); | ||
|
||
const ToggleGroup = React.forwardRef< | ||
React.ElementRef<typeof ToggleGroupPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> & | ||
VariantProps<typeof toggleVariants> | ||
>(({ className, variant, size, children, ...props }, ref) => ( | ||
<ToggleGroupPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
'pr-twp pr-flex pr-items-center pr-justify-center pr-gap-1 pr-font-sans', | ||
className, | ||
)} | ||
{...props} | ||
> | ||
<ToggleGroupContext.Provider | ||
// Suppress warning produced by imported shadcn code | ||
// eslint-disable-next-line react/jsx-no-constructed-context-values | ||
value={{ variant, size }} | ||
> | ||
{children} | ||
</ToggleGroupContext.Provider> | ||
</ToggleGroupPrimitive.Root> | ||
)); | ||
|
||
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName; | ||
|
||
const ToggleGroupItem = React.forwardRef< | ||
React.ElementRef<typeof ToggleGroupPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> & | ||
VariantProps<typeof toggleVariants> | ||
>(({ className, children, variant, size, ...props }, ref) => { | ||
const context = React.useContext(ToggleGroupContext); | ||
|
||
return ( | ||
<ToggleGroupPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
toggleVariants({ | ||
variant: context.variant || variant, | ||
size: context.size || size, | ||
}), | ||
className, | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</ToggleGroupPrimitive.Item> | ||
); | ||
}); | ||
|
||
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName; | ||
|
||
export { ToggleGroup, ToggleGroupItem }; |
42 changes: 42 additions & 0 deletions
42
lib/platform-bible-react/src/components/shadcn-ui/toggle.tsx
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,42 @@ | ||
import React from 'react'; | ||
import * as TogglePrimitive from '@radix-ui/react-toggle'; | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
|
||
import { cn } from '@/utils/shadcn-ui.util'; | ||
|
||
const toggleVariants = cva( | ||
'pr-twp pr-font-sans pr-inline-flex pr-items-center pr-justify-center pr-rounded-md pr-text-sm pr-font-medium pr-ring-offset-background pr-transition-colors hover:pr-bg-muted hover:pr-text-muted-foreground focus-visible:pr-outline-none focus-visible:pr-ring-2 focus-visible:pr-ring-ring focus-visible:pr-ring-offset-2 disabled:pr-pointer-events-none disabled:pr-opacity-50 data-[state=on]:pr-bg-accent data-[state=on]:pr-text-accent-foreground', | ||
{ | ||
variants: { | ||
variant: { | ||
default: 'pr-bg-transparent', | ||
outline: | ||
'pr-border pr-border-input pr-bg-transparent hover:pr-bg-accent hover:pr-text-accent-foreground', | ||
}, | ||
size: { | ||
default: 'pr-h-10 pr-px-3', | ||
sm: 'pr-h-9 pr-px-2.5', | ||
lg: 'pr-h-11 pr-px-5', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'default', | ||
size: 'default', | ||
}, | ||
}, | ||
); | ||
|
||
const Toggle = React.forwardRef< | ||
React.ElementRef<typeof TogglePrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants> | ||
>(({ className, variant, size, ...props }, ref) => ( | ||
<TogglePrimitive.Root | ||
ref={ref} | ||
className={cn(toggleVariants({ variant, size, className }))} | ||
{...props} | ||
/> | ||
)); | ||
|
||
Toggle.displayName = TogglePrimitive.Root.displayName; | ||
|
||
export { Toggle, toggleVariants }; |
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
16 changes: 8 additions & 8 deletions
16
lib/platform-bible-react/src/preview/pages/components/basics/slider.examples.component.tsx
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,21 +1,21 @@ | ||
import Slider from '@/components/mui/slider.component'; | ||
import { Slider } from '@/components/shadcn-ui/slider'; | ||
import { useState } from 'react'; | ||
|
||
export default function SliderExamples() { | ||
const [sliderValue, setSlider] = useState(3); | ||
const [sliderValue, setSlider] = useState<number[]>([33]); | ||
return ( | ||
<> | ||
Wrongly using MUI slider right now 😬 | ||
<Slider /> | ||
<Slider isDisabled /> | ||
<Slider | ||
className="pr-h-10" | ||
min={0} | ||
max={5} | ||
max={100} | ||
step={1} | ||
value={sliderValue} | ||
onChange={(_e, value) => setSlider(Array.isArray(value) ? value?.[0] : value)} | ||
onValueChange={setSlider} | ||
/> | ||
{/* Wondering in which case the slider would output a number[] as its value 🤷 */} | ||
{sliderValue} | ||
|
||
<Slider className="pr-h-10" disabled min={0} max={100} step={1} defaultValue={[50]} /> | ||
</> | ||
); | ||
} |
Oops, something went wrong.