Skip to content

Commit 0efb4bc

Browse files
SutuSebastianSebastian SutuSebastian Sutu
authored
refactor(components): separate AdvancedRating from Rating theming (#1109)
* refactor(components): separate theme `RatingAdvanced` from `Rating` since they cant ever be coupled * fix typo --------- Co-authored-by: Sebastian Sutu <sebastian.sutu@sensidev.com> Co-authored-by: Sebastian Sutu <sebastian.sutu@stainless-code.com>
1 parent 8d14544 commit 0efb4bc

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

content/docs/components/rating.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ Use this component as an advanced layout for user ratings that include both the
4747

4848
To learn more about how to customize the appearance of components, please see the [Theme docs](/docs/customize/theme).
4949

50+
### Rating theme
51+
5052
<Theme name="rating" />
5153

54+
### Advanced rating theme
55+
56+
<Theme name="ratingAdvanced" />
57+
5258
## References
5359

5460
- [Flowbite Rating](https://flowbite.com/docs/components/rating/)

src/components/Flowbite/FlowbiteTheme.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type { FlowbitePaginationTheme } from '../Pagination';
2525
import type { FlowbiteProgressTheme } from '../Progress';
2626
import type { FlowbiteRadioTheme } from '../Radio';
2727
import type { FlowbiteRangeSliderTheme } from '../RangeSlider';
28-
import type { FlowbiteRatingTheme } from '../Rating';
28+
import type { FlowbiteRatingAdvancedTheme, FlowbiteRatingTheme } from '../Rating';
2929
import type { FlowbiteSelectTheme } from '../Select';
3030
import type { FlowbiteSidebarTheme } from '../Sidebar';
3131
import type { FlowbiteSpinnerTheme } from '../Spinner';
@@ -59,6 +59,7 @@ export interface FlowbiteTheme {
5959
modal: FlowbiteModalTheme;
6060
navbar: FlowbiteNavbarTheme;
6161
rating: FlowbiteRatingTheme;
62+
ratingAdvanced: FlowbiteRatingAdvancedTheme;
6263
pagination: FlowbitePaginationTheme;
6364
sidebar: FlowbiteSidebarTheme;
6465
progress: FlowbiteProgressTheme;

src/components/Rating/Rating.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { twMerge } from 'tailwind-merge';
55
import { mergeDeep } from '../../helpers/merge-deep';
66
import { getTheme } from '../../theme-store';
77
import type { DeepPartial } from '../../types';
8-
import type { FlowbiteRatingAdvancedTheme } from './RatingAdvanced';
98
import { RatingAdvanced } from './RatingAdvanced';
109
import { RatingContext } from './RatingContext';
1110
import type { FlowbiteRatingStarTheme, FlowbiteStarSizes } from './RatingStar';
@@ -16,7 +15,6 @@ export interface FlowbiteRatingTheme {
1615
base: string;
1716
};
1817
star: FlowbiteRatingStarTheme;
19-
advanced: FlowbiteRatingAdvancedTheme;
2018
}
2119

2220
export interface RatingProps extends ComponentProps<'div'> {

src/components/Rating/RatingAdvanced.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const RatingAdvanced: FC<RatingAdvancedProps> = ({
2626
theme: customTheme = {},
2727
...props
2828
}) => {
29-
const theme = mergeDeep(getTheme().rating.advanced, customTheme);
29+
const theme = mergeDeep(getTheme().ratingAdvanced, customTheme);
3030

3131
return (
3232
<div className={twMerge(theme.base, className)} {...props}>

src/components/Rating/theme.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
import type { FlowbiteRatingTheme } from './Rating';
2+
import { FlowbiteRatingAdvancedTheme } from './RatingAdvanced';
23

34
export const ratingTheme: FlowbiteRatingTheme = {
45
root: {
56
base: 'flex items-center',
67
},
7-
advanced: {
8-
base: 'flex items-center',
9-
label: 'text-sm font-medium text-cyan-600 dark:text-cyan-500',
10-
progress: {
11-
base: 'mx-4 h-5 w-2/4 rounded bg-gray-200 dark:bg-gray-700',
12-
fill: 'h-5 rounded bg-yellow-400',
13-
label: 'text-sm font-medium text-cyan-600 dark:text-cyan-500',
14-
},
15-
},
168
star: {
179
empty: 'text-gray-300 dark:text-gray-500',
1810
filled: 'text-yellow-400',
@@ -23,3 +15,13 @@ export const ratingTheme: FlowbiteRatingTheme = {
2315
},
2416
},
2517
};
18+
19+
export const ratingAdvancedTheme: FlowbiteRatingAdvancedTheme = {
20+
base: 'flex items-center',
21+
label: 'text-sm font-medium text-cyan-600 dark:text-cyan-500',
22+
progress: {
23+
base: 'mx-4 h-5 w-2/4 rounded bg-gray-200 dark:bg-gray-700',
24+
fill: 'h-5 rounded bg-yellow-400',
25+
label: 'text-sm font-medium text-cyan-600 dark:text-cyan-500',
26+
},
27+
};

src/theme.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { paginationTheme } from './components/Pagination/theme';
2525
import { progressTheme } from './components/Progress/theme';
2626
import { radioTheme } from './components/Radio/theme';
2727
import { rangeSliderTheme } from './components/RangeSlider/theme';
28-
import { ratingTheme } from './components/Rating/theme';
28+
import { ratingAdvancedTheme, ratingTheme } from './components/Rating/theme';
2929
import { selectTheme } from './components/Select/theme';
3030
import { sidebarTheme } from './components/Sidebar/theme';
3131
import { spinnerTheme } from './components/Spinner/theme';
@@ -67,6 +67,7 @@ export const theme: FlowbiteTheme = {
6767
radio: radioTheme,
6868
rangeSlider: rangeSliderTheme,
6969
rating: ratingTheme,
70+
ratingAdvanced: ratingAdvancedTheme,
7071
select: selectTheme,
7172
textInput: textInputTheme,
7273
textarea: textareaTheme,

0 commit comments

Comments
 (0)