From ad0502b57f11391aebfa230cb2234bad5a61e280 Mon Sep 17 00:00:00 2001 From: Arnaud Touillet <49291068+Jacouille@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:18:26 -0400 Subject: [PATCH] [core] applied PR review changes --- .../src/components/Spoiler/Spoiler.module.css | 3 ++- .../src/components/Spoiler/Spoiler.tsx | 23 ++++++------------- .../src/data/Spoiler.styles-api.ts | 2 -- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/mantine-core/src/components/Spoiler/Spoiler.module.css b/src/mantine-core/src/components/Spoiler/Spoiler.module.css index c1aaa2c9374..83d16f03c40 100644 --- a/src/mantine-core/src/components/Spoiler/Spoiler.module.css +++ b/src/mantine-core/src/components/Spoiler/Spoiler.module.css @@ -1,8 +1,9 @@ .root { position: relative; + margin-bottom: var(--_spoiler-margin-bottom); &[data-has-spoiler] { - margin-bottom: var(--spoiler-margin-bottom, rem(24px)); + --_spoiler-margin-bottom: rem(24px); } } diff --git a/src/mantine-core/src/components/Spoiler/Spoiler.tsx b/src/mantine-core/src/components/Spoiler/Spoiler.tsx index 19a28127768..ec95e780fb7 100644 --- a/src/mantine-core/src/components/Spoiler/Spoiler.tsx +++ b/src/mantine-core/src/components/Spoiler/Spoiler.tsx @@ -11,15 +11,13 @@ import { createVarsResolver, Factory, rem, - getSpacing, - MantineSpacing, } from '../../core'; import { Anchor } from '../Anchor'; import classes from './Spoiler.module.css'; export type SpoilerStylesNames = 'root' | 'control' | 'content'; export type SpoilerCssVariables = { - root: '--spoiler-transition-duration' | '--spoiler-margin-bottom'; + root: '--spoiler-transition-duration'; }; export interface SpoilerProps @@ -43,9 +41,6 @@ export interface SpoilerProps /** Spoiler reveal transition duration in ms, set 0 or null to turn off animation, `200` by default */ transitionDuration?: number; - - /** Margin bottom applied when the control button is shown, `rem(24px)` by default */ - activeSpoilerMarginBottom?: MantineSpacing; } export type SpoilerFactory = Factory<{ @@ -60,16 +55,12 @@ const defaultProps: Partial = { initialState: false, }; -const varsResolver = createVarsResolver( - (_, { transitionDuration, activeSpoilerMarginBottom }) => ({ - root: { - '--spoiler-transition-duration': - transitionDuration !== undefined ? `${transitionDuration}ms` : undefined, - '--spoiler-margin-bottom': - activeSpoilerMarginBottom !== undefined ? getSpacing(activeSpoilerMarginBottom) : undefined, - }, - }) -); +const varsResolver = createVarsResolver((_, { transitionDuration }) => ({ + root: { + '--spoiler-transition-duration': + transitionDuration !== undefined ? `${transitionDuration}ms` : undefined, + }, +})); export const Spoiler = factory((_props, ref) => { const props = useProps('Spoiler', defaultProps, _props); diff --git a/src/mantine-styles-api/src/data/Spoiler.styles-api.ts b/src/mantine-styles-api/src/data/Spoiler.styles-api.ts index 6cbe53544b9..55d50bbcba2 100644 --- a/src/mantine-styles-api/src/data/Spoiler.styles-api.ts +++ b/src/mantine-styles-api/src/data/Spoiler.styles-api.ts @@ -11,8 +11,6 @@ export const SpoilerStylesApi: StylesApiData = { vars: { root: { '--spoiler-transition-duration': 'Controls transition duration', - '--spoiler-margin-bottom': - 'Controls the margin bottom applied when the control button is shown', }, },