mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
adjust rating component to match theme sizes
This commit is contained in:
@@ -1,3 +1,23 @@
|
|||||||
|
.root.xs {
|
||||||
|
--rating-size: var(--theme-font-size-xs) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.root.sm {
|
||||||
|
--rating-size: var(--theme-font-size-sm) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.root.md {
|
||||||
|
--rating-size: var(--theme-font-size-md) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.root.lg {
|
||||||
|
--rating-size: var(--theme-font-size-lg) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.root.xl {
|
||||||
|
--rating-size: var(--theme-font-size-xl) !important;
|
||||||
|
}
|
||||||
|
|
||||||
.symbol-body {
|
.symbol-body {
|
||||||
svg {
|
svg {
|
||||||
stroke: alpha(var(--theme-colors-foreground), 0.7);
|
stroke: alpha(var(--theme-colors-foreground), 0.7);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Rating as MantineRating, RatingProps as MantineRatingProps } from '@mantine/core';
|
import { Rating as MantineRating, RatingProps as MantineRatingProps } from '@mantine/core';
|
||||||
|
import clsx from 'clsx';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
@@ -6,7 +7,7 @@ import styles from './rating.module.css';
|
|||||||
|
|
||||||
interface RatingProps extends MantineRatingProps {}
|
interface RatingProps extends MantineRatingProps {}
|
||||||
|
|
||||||
export const Rating = ({ classNames, onChange, style, ...props }: RatingProps) => {
|
export const Rating = ({ classNames, onChange, size, style, ...props }: RatingProps) => {
|
||||||
const valueChange = useCallback(
|
const valueChange = useCallback(
|
||||||
(rating: number) => {
|
(rating: number) => {
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
@@ -25,6 +26,13 @@ export const Rating = ({ classNames, onChange, style, ...props }: RatingProps) =
|
|||||||
return (
|
return (
|
||||||
<MantineRating
|
<MantineRating
|
||||||
classNames={{
|
classNames={{
|
||||||
|
root: clsx(styles.root, {
|
||||||
|
[styles.lg]: size === 'lg',
|
||||||
|
[styles.md]: size === 'md',
|
||||||
|
[styles.sm]: size === 'sm',
|
||||||
|
[styles.xl]: size === 'xl',
|
||||||
|
[styles.xs]: size === 'xs',
|
||||||
|
}),
|
||||||
symbolBody: styles.symbolBody,
|
symbolBody: styles.symbolBody,
|
||||||
...classNames,
|
...classNames,
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user