Skip to content

Commit

Permalink
[@mantine/core] Spoiler: remove margin-bottom when "Show more" is hid…
Browse files Browse the repository at this point in the history
…den (#4928)

* [@mantine/core] Spoiler: removed extra margin bottom when "Show more" is hidden

* [docs] Added spoiler modifier

* [core] fix test issues

* [core] applied PR review changes

* [core] applied PR review changes
  • Loading branch information
Jacouille authored Oct 2, 2023
1 parent 8894708 commit 8e0a370
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/mantine-core/src/components/Spoiler/Spoiler.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.root {
position: relative;
margin-bottom: rem(24px);
margin-bottom: var(--_spoiler-margin-bottom);

&[data-has-spoiler] {
--_spoiler-margin-bottom: rem(24px);
}
}

.content {
Expand Down
8 changes: 7 additions & 1 deletion src/mantine-core/src/components/Spoiler/Spoiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ export const Spoiler = factory<SpoilerFactory>((_props, ref) => {
const spoilerMoreContent = show ? hideLabel : showLabel;

return (
<Box {...getStyles('root')} id={_id} ref={ref} {...others}>
<Box
{...getStyles('root')}
id={_id}
ref={ref}
data-has-spoiler={spoiler || undefined}
{...others}
>
{spoiler && (
<Anchor
component="button"
Expand Down
8 changes: 8 additions & 0 deletions src/mantine-styles-api/src/data/Spoiler.styles-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ export const SpoilerStylesApi: StylesApiData<SpoilerFactory> = {
'--spoiler-transition-duration': 'Controls transition duration',
},
},

modifiers: [
{
modifier: 'data-has-spoiler',
selector: 'root',
condition: 'Whether the control button is shown or not',
},
],
};

0 comments on commit 8e0a370

Please sign in to comment.