Skip to content

Commit

Permalink
[core] applied PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacouille committed Oct 1, 2023
1 parent bbb68d6 commit ad0502b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/mantine-core/src/components/Spoiler/Spoiler.module.css
Original file line number Diff line number Diff line change
@@ -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);
}
}

Expand Down
23 changes: 7 additions & 16 deletions src/mantine-core/src/components/Spoiler/Spoiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<{
Expand All @@ -60,16 +55,12 @@ const defaultProps: Partial<SpoilerProps> = {
initialState: false,
};

const varsResolver = createVarsResolver<SpoilerFactory>(
(_, { transitionDuration, activeSpoilerMarginBottom }) => ({
root: {
'--spoiler-transition-duration':
transitionDuration !== undefined ? `${transitionDuration}ms` : undefined,
'--spoiler-margin-bottom':
activeSpoilerMarginBottom !== undefined ? getSpacing(activeSpoilerMarginBottom) : undefined,
},
})
);
const varsResolver = createVarsResolver<SpoilerFactory>((_, { transitionDuration }) => ({
root: {
'--spoiler-transition-duration':
transitionDuration !== undefined ? `${transitionDuration}ms` : undefined,
},
}));

export const Spoiler = factory<SpoilerFactory>((_props, ref) => {
const props = useProps('Spoiler', defaultProps, _props);
Expand Down
2 changes: 0 additions & 2 deletions src/mantine-styles-api/src/data/Spoiler.styles-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export const SpoilerStylesApi: StylesApiData<SpoilerFactory> = {
vars: {
root: {
'--spoiler-transition-duration': 'Controls transition duration',
'--spoiler-margin-bottom':
'Controls the margin bottom applied when the control button is shown',
},
},

Expand Down

0 comments on commit ad0502b

Please sign in to comment.