mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
Migrate Mantine components to v5
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import React, { ReactNode } from 'react';
|
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
||||||
import { ActionIcon, ActionIconProps, TooltipProps } from '@mantine/core';
|
import { ActionIcon, ActionIconProps, TooltipProps } from '@mantine/core';
|
||||||
import { Tooltip } from '../tooltip/Tooltip';
|
import { Tooltip } from '../tooltip/Tooltip';
|
||||||
|
|
||||||
type MantineIconButtonProps = ActionIconProps &
|
type MantineIconButtonProps = ActionIconProps &
|
||||||
React.ComponentPropsWithoutRef<'button'>;
|
ComponentPropsWithoutRef<'button'>;
|
||||||
|
|
||||||
interface IconButtonProps extends MantineIconButtonProps {
|
interface IconButtonProps extends MantineIconButtonProps {
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { ReactNode } from 'react';
|
import {
|
||||||
|
ComponentPropsWithoutRef,
|
||||||
|
ComponentPropsWithRef,
|
||||||
|
ReactNode,
|
||||||
|
} from 'react';
|
||||||
import {
|
import {
|
||||||
Text as MantineText,
|
Text as MantineText,
|
||||||
TextProps as MantineTextProps,
|
TextProps as MantineTextProps,
|
||||||
@@ -8,7 +12,10 @@ import styled from 'styled-components';
|
|||||||
import { Font } from 'renderer/styles';
|
import { Font } from 'renderer/styles';
|
||||||
import { textEllipsis } from 'renderer/styles/mixins';
|
import { textEllipsis } from 'renderer/styles/mixins';
|
||||||
|
|
||||||
interface TextProps extends MantineTextProps<'div'> {
|
type MantineTextDivProps = MantineTextProps & ComponentPropsWithoutRef<'div'>;
|
||||||
|
type MantineTextLinkProps = MantineTextProps & ComponentPropsWithRef<'link'>;
|
||||||
|
|
||||||
|
interface TextProps extends MantineTextDivProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
font?: Font;
|
font?: Font;
|
||||||
link?: boolean;
|
link?: boolean;
|
||||||
@@ -19,7 +26,7 @@ interface TextProps extends MantineTextProps<'div'> {
|
|||||||
weight?: number;
|
weight?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LinkTextProps extends MantineTextProps<'Link'> {
|
interface LinkTextProps extends MantineTextLinkProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
font?: Font;
|
font?: Font;
|
||||||
link?: boolean;
|
link?: boolean;
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import { Tooltip as MantineTooltip, TooltipProps } from '@mantine/core';
|
import { Tooltip as MantineTooltip, TooltipProps } from '@mantine/core';
|
||||||
import styles from './Tooltip.module.scss';
|
|
||||||
|
|
||||||
export const Tooltip = ({ children, ...rest }: TooltipProps) => {
|
export const Tooltip = ({ children, ...rest }: TooltipProps) => {
|
||||||
return (
|
return (
|
||||||
<MantineTooltip
|
<MantineTooltip
|
||||||
classNames={{ arrow: styles.arrow, body: styles.body }}
|
|
||||||
radius="xs"
|
radius="xs"
|
||||||
styles={{
|
styles={{
|
||||||
arrow: {
|
arrow: {
|
||||||
background: 'var(--tooltip-bg)',
|
background: 'var(--tooltip-bg)',
|
||||||
},
|
},
|
||||||
body: {
|
root: {
|
||||||
background: 'var(--tooltip-bg)',
|
background: 'var(--tooltip-bg)',
|
||||||
color: 'var(--tooltip-text-color)',
|
color: 'var(--tooltip-text-color)',
|
||||||
padding: '5px',
|
padding: '5px',
|
||||||
@@ -25,8 +23,9 @@ export const Tooltip = ({ children, ...rest }: TooltipProps) => {
|
|||||||
|
|
||||||
Tooltip.defaultProps = {
|
Tooltip.defaultProps = {
|
||||||
openDelay: 0,
|
openDelay: 0,
|
||||||
placement: 'center',
|
position: 'top',
|
||||||
transition: 'fade',
|
transition: 'fade',
|
||||||
transitionDuration: 250,
|
transitionDuration: 250,
|
||||||
withArrow: true,
|
withArrow: true,
|
||||||
|
withinPortal: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
||||||
import {
|
import {
|
||||||
TooltipProps,
|
TooltipProps,
|
||||||
UnstyledButton,
|
UnstyledButton,
|
||||||
@@ -8,7 +8,9 @@ import { motion } from 'framer-motion';
|
|||||||
import styled, { css } from 'styled-components';
|
import styled, { css } from 'styled-components';
|
||||||
import { Tooltip } from 'renderer/components';
|
import { Tooltip } from 'renderer/components';
|
||||||
|
|
||||||
interface PlayerButtonProps extends UnstyledButtonProps<'button'> {
|
type MantineButtonProps = UnstyledButtonProps &
|
||||||
|
ComponentPropsWithoutRef<'button'>;
|
||||||
|
interface PlayerButtonProps extends MantineButtonProps {
|
||||||
icon: ReactNode;
|
icon: ReactNode;
|
||||||
tooltip?: Omit<TooltipProps, 'children'>;
|
tooltip?: Omit<TooltipProps, 'children'>;
|
||||||
variant: 'main' | 'secondary';
|
variant: 'main' | 'secondary';
|
||||||
@@ -107,13 +109,13 @@ export const PlayerButton = ({
|
|||||||
}: PlayerButtonProps) => {
|
}: PlayerButtonProps) => {
|
||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
return (
|
return (
|
||||||
<Tooltip {...tooltip}>
|
|
||||||
<MotionWrapper variant={variant}>
|
<MotionWrapper variant={variant}>
|
||||||
|
<Tooltip {...tooltip}>
|
||||||
<StyledPlayerButton variant={variant} {...rest}>
|
<StyledPlayerButton variant={variant} {...rest}>
|
||||||
{icon}
|
{icon}
|
||||||
</StyledPlayerButton>
|
</StyledPlayerButton>
|
||||||
</MotionWrapper>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
</MotionWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user