Skip to content

Commit c217b6b

Browse files
authored
Merge pull request #3677 from Lenghak/main
style(emoji & color picker): fix styling & dependencies with color pi…
2 parents 3f9f97c + 3df78e6 commit c217b6b

File tree

10 files changed

+140
-106
lines changed

10 files changed

+140
-106
lines changed

apps/www/content/docs/components/changelog.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Use the [CLI](https://platejs.org/docs/components/cli) to install the latest ver
1111

1212
## October 2024 #15
1313

14+
### October 27 #15.6
15+
16+
- Fixed and modified some styles in emoji and color picker
17+
1418
### October 26 #15.5
1519

1620
- Rename `indent-todo-marker-component` to `indent-todo-marker`.

apps/www/public/r/styles/default/color-dropdown-menu.json

+4-4
Large diffs are not rendered by default.

apps/www/public/r/styles/default/emoji-dropdown-menu.json

+2-2
Large diffs are not rendered by default.

apps/www/src/components/icons.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
CornerUpLeft,
3131
DownloadCloud,
3232
DownloadIcon,
33+
EraserIcon,
3334
ExternalLink,
3435
Eye,
3536
File,
@@ -418,6 +419,7 @@ export const Icons = {
418419
code: Code2,
419420
codeblock: FileCode,
420421
color: Baseline,
422+
colorClear: EraserIcon,
421423
column: RectangleVertical,
422424
combine: Combine,
423425
comment: MessageSquare,

apps/www/src/registry/default/plate-ui/color-dropdown-menu-items.tsx

+15-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import type { DropdownMenuItemProps } from '@radix-ui/react-dropdown-menu';
77
import { cn } from '@udecode/cn';
88
import { Check } from 'lucide-react';
99

10-
import type { TColor } from './color-dropdown-menu';
11-
1210
import { buttonVariants } from './button';
1311
import { DropdownMenuItem } from './dropdown-menu';
1412
import {
@@ -18,6 +16,12 @@ import {
1816
TooltipTrigger,
1917
} from './tooltip';
2018

19+
export type TColor = {
20+
isBrightColor: boolean;
21+
name: string;
22+
value: string;
23+
};
24+
2125
type ColorDropdownMenuItemProps = {
2226
isBrightColor: boolean;
2327
isSelected: boolean;
@@ -42,8 +46,8 @@ export function ColorDropdownMenuItem({
4246
isMenu: true,
4347
variant: 'outline',
4448
}),
45-
'size-6 border border-solid border-muted p-0',
46-
!isBrightColor && 'border-transparent text-white',
49+
'flex size-6 items-center justify-center rounded-full border border-solid border-muted p-0 transition-all hover:scale-125',
50+
!isBrightColor && 'border-transparent text-white hover:!text-white',
4751
className
4852
)}
4953
style={{ backgroundColor: value }}
@@ -53,14 +57,14 @@ export function ColorDropdownMenuItem({
5357
}}
5458
{...props}
5559
>
56-
{isSelected ? <Check /> : null}
60+
{isSelected ? <Check className="size-3" /> : null}
5761
</DropdownMenuItem>
5862
);
5963

6064
return name ? (
6165
<Tooltip>
6266
<TooltipTrigger>{content}</TooltipTrigger>
63-
<TooltipContent>{name}</TooltipContent>
67+
<TooltipContent className="mb-1 capitalize">{name}</TooltipContent>
6468
</Tooltip>
6569
) : (
6670
content
@@ -82,7 +86,10 @@ export function ColorDropdownMenuItems({
8286
}: ColorDropdownMenuItemsProps) {
8387
return (
8488
<div
85-
className={cn('grid grid-cols-[repeat(10,1fr)] gap-1', className)}
89+
className={cn(
90+
'grid grid-cols-[repeat(10,1fr)] place-items-center gap-1',
91+
className
92+
)}
8693
{...props}
8794
>
8895
<TooltipProvider>
@@ -96,6 +103,7 @@ export function ColorDropdownMenuItems({
96103
updateColor={updateColor}
97104
/>
98105
))}
106+
{props.children}
99107
</TooltipProvider>
100108
</div>
101109
);

apps/www/src/registry/default/plate-ui/color-dropdown-menu.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use client';
22

3-
import React from 'react';
4-
53
import type { DropdownMenuProps } from '@radix-ui/react-dropdown-menu';
64

75
import {
@@ -18,12 +16,6 @@ import {
1816
} from './dropdown-menu';
1917
import { ToolbarButton } from './toolbar';
2018

21-
export type TColor = {
22-
isBrightColor: boolean;
23-
name: string;
24-
value: string;
25-
};
26-
2719
type ColorDropdownMenuProps = {
2820
nodeType: string;
2921
tooltip?: string;

apps/www/src/registry/default/plate-ui/color-picker.tsx

+52-34
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ import React from 'react';
44

55
import { cn, withRef } from '@udecode/cn';
66

7-
import type { TColor } from './color-dropdown-menu';
7+
import { Icons } from '@/components/icons';
88

99
import { buttonVariants } from './button';
10-
import { ColorDropdownMenuItems } from './color-dropdown-menu-items';
11-
import { ColorsCustom } from './colors-custom';
12-
import { DropdownMenuItem } from './dropdown-menu';
13-
import { Separator } from './separator';
10+
import {
11+
type TColor,
12+
ColorDropdownMenuItems,
13+
} from './color-dropdown-menu-items';
14+
import { ColorCustom } from './colors-custom';
15+
import {
16+
DropdownMenuGroup,
17+
DropdownMenuItem,
18+
DropdownMenuLabel,
19+
DropdownMenuSeparator,
20+
} from './dropdown-menu';
1421

1522
export const ColorPickerContent = withRef<
1623
'div',
@@ -37,36 +44,47 @@ export const ColorPickerContent = withRef<
3744
ref
3845
) => {
3946
return (
40-
<div
41-
ref={ref}
42-
className={cn('flex flex-col gap-4 p-4', className)}
43-
{...props}
44-
>
45-
<ColorsCustom
46-
color={color}
47-
colors={colors}
48-
customColors={customColors}
49-
updateColor={updateColor}
50-
updateCustomColor={updateCustomColor}
51-
/>
52-
53-
<Separator />
54-
55-
<ColorDropdownMenuItems
56-
color={color}
57-
colors={colors}
58-
updateColor={updateColor}
59-
/>
47+
<div ref={ref} className={cn('flex flex-col', className)} {...props}>
48+
<DropdownMenuLabel>Color Picker</DropdownMenuLabel>
49+
<DropdownMenuGroup>
50+
<ColorCustom
51+
color={color}
52+
className="p-2"
53+
colors={colors}
54+
customColors={customColors}
55+
updateColor={updateColor}
56+
updateCustomColor={updateCustomColor}
57+
/>
58+
</DropdownMenuGroup>
59+
<DropdownMenuSeparator />
60+
<DropdownMenuGroup>
61+
<ColorDropdownMenuItems
62+
color={color}
63+
className="p-2"
64+
colors={colors}
65+
updateColor={updateColor}
66+
/>
67+
</DropdownMenuGroup>
6068
{color && (
61-
<DropdownMenuItem
62-
className={buttonVariants({
63-
isMenu: true,
64-
variant: 'outline',
65-
})}
66-
onClick={clearColor}
67-
>
68-
Clear
69-
</DropdownMenuItem>
69+
<React.Fragment>
70+
<DropdownMenuSeparator />
71+
<DropdownMenuGroup>
72+
<DropdownMenuItem
73+
className={cn(
74+
buttonVariants({
75+
isMenu: false,
76+
size: 'sm',
77+
variant: 'ghost',
78+
}),
79+
'w-full justify-start'
80+
)}
81+
onClick={clearColor}
82+
>
83+
<Icons.colorClear className="mr-2" />
84+
<span>Clear</span>
85+
</DropdownMenuItem>
86+
</DropdownMenuGroup>
87+
</React.Fragment>
7088
)}
7189
</div>
7290
);
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
'use client';
22

3-
import React from 'react';
3+
import React, { type ComponentPropsWithoutRef } from 'react';
44

5+
import { cn } from '@udecode/cn';
56
import {
67
useColorsCustom,
78
useColorsCustomState,
89
} from '@udecode/plate-font/react';
910

10-
import type { TColor } from './color-dropdown-menu';
11+
import { Icons } from '@/components/icons';
1112

1213
import { buttonVariants } from './button';
13-
import { ColorDropdownMenuItems } from './color-dropdown-menu-items';
14+
import {
15+
type TColor,
16+
ColorDropdownMenuItems,
17+
} from './color-dropdown-menu-items';
1418
import { ColorInput } from './color-input';
19+
20+
// import { ColorInput } from './color-input';
1521
import { DropdownMenuItem } from './dropdown-menu';
1622

17-
type ColorsCustomProps = {
23+
type ColorCustomProps = {
1824
colors: TColor[];
1925
customColors: TColor[];
2026
updateColor: (color: string) => void;
2127
updateCustomColor: (color: string) => void;
2228
color?: string;
23-
};
29+
} & ComponentPropsWithoutRef<'div'>;
2430

25-
export function ColorsCustom({
31+
export function ColorCustom({
32+
className,
2633
color,
2734
colors,
2835
customColors,
2936
updateColor,
3037
updateCustomColor,
31-
}: ColorsCustomProps) {
38+
...props
39+
}: ColorCustomProps) {
3240
const state = useColorsCustomState({
3341
color,
3442
colors,
@@ -38,24 +46,29 @@ export function ColorsCustom({
3846
const { inputProps, menuItemProps } = useColorsCustom(state);
3947

4048
return (
41-
<div className="flex flex-col gap-4">
42-
<ColorInput {...inputProps}>
43-
<DropdownMenuItem
44-
className={buttonVariants({
45-
isMenu: true,
46-
variant: 'outline',
47-
})}
48-
{...menuItemProps}
49-
>
50-
CUSTOM
51-
</DropdownMenuItem>
52-
</ColorInput>
53-
49+
<div className={cn('relative flex flex-col gap-4', className)} {...props}>
5450
<ColorDropdownMenuItems
5551
color={color}
5652
colors={state.computedColors}
5753
updateColor={updateColor}
58-
/>
54+
>
55+
<ColorInput {...inputProps}>
56+
<DropdownMenuItem
57+
className={cn(
58+
buttonVariants({
59+
isMenu: true,
60+
size: 'icon',
61+
variant: 'outline',
62+
}),
63+
'absolute bottom-2 right-2 top-1.5 flex size-7 items-center justify-center rounded-full'
64+
)}
65+
{...menuItemProps}
66+
>
67+
<span className="sr-only">Custom</span>
68+
<Icons.add />
69+
</DropdownMenuItem>
70+
</ColorInput>
71+
</ColorDropdownMenuItems>
5972
</div>
6073
);
6174
}

apps/www/src/registry/default/plate-ui/emoji-picker-content.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const Button = memo(
4848
className="absolute inset-0 rounded-full opacity-0 group-hover:opacity-100"
4949
aria-hidden="true"
5050
/>
51-
<span style={{ position: 'relative' }} data-emoji-set="native">
51+
<span className="relative" data-emoji-set="native">
5252
{emoji.skins[0].native}
5353
</span>
5454
</button>

0 commit comments

Comments
 (0)