Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkeJohn authored Nov 14, 2024
2 parents 6a73094 + f575415 commit d3c2e39
Show file tree
Hide file tree
Showing 150 changed files with 5,178 additions and 519 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ apps/mantine.dev/.cache
apps/mantine.dev/out
apps/mantine.dev/.next
apps/mantine.dev/src/.docgen/
.samples
5 changes: 5 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ const storiesPath = !argv._[1]

export default {
stories: storiesPath,
core: {
disableWhatsNewNotifications: true,
disableTelemetry: true,
enableCrashReports: false,
},

addons: [
getAbsolutePath('storybook-dark-mode'),
Expand Down
7 changes: 6 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import { Notifications } from '@mantine/notifications';
import { ShikiProvider } from '@mantinex/shiki';
import { theme } from '../apps/mantine.dev/theme';

export const parameters = { layout: 'fullscreen' };
export const parameters = {
layout: 'fullscreen',
options: {
showPanel: false,
},
};

const channel = addons.getChannel();

Expand Down
108 changes: 108 additions & 0 deletions apps/help.mantine.dev/src/demos/NestedPopovers.demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Button, Popover, Select } from '@mantine/core';
import { MantineDemo } from '@mantinex/demo';

const codeWithIssue = `
import { Button, Popover, Select } from '@mantine/core';
import { InputBase } from '@mantine/core';
function Demo() {
return (
<Popover width={200} position="bottom" withArrow shadow="md">
<Popover.Target>
<Button>Toggle popover</Button>
</Popover.Target>
<Popover.Dropdown>
<Select
placeholder="Choose your framework"
data={[
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'angular', label: 'Angular' },
]}
/>
</Popover.Dropdown>
</Popover>
);
}
`;

function DemoWithIssue() {
return (
<Popover width={200} position="bottom" withArrow shadow="md">
<Popover.Target>
<Button>Toggle popover</Button>
</Popover.Target>
<Popover.Dropdown>
<Select
data={[
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'angular', label: 'Angular' },
]}
placeholder="Choose your framework"
/>
</Popover.Dropdown>
</Popover>
);
}

export const NestedPopovers: MantineDemo = {
type: 'code',
component: DemoWithIssue,
code: codeWithIssue,
centered: true,
};

const codeWithoutIssue = `
import { Button, Popover, Select } from '@mantine/core';
import { InputBase } from '@mantine/core';
function Demo() {
return (
<Popover width={200} position="bottom" withArrow shadow="md">
<Popover.Target>
<Button>Toggle popover</Button>
</Popover.Target>
<Popover.Dropdown>
<Select
comboboxProps={{ withinPortal: false }}
placeholder="Choose your framework"
data={[
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'angular', label: 'Angular' },
]}
/>
</Popover.Dropdown>
</Popover>
);
}
`;

function DemoWithoutIssue() {
return (
<Popover width={200} position="bottom" withArrow shadow="md">
<Popover.Target>
<Button>Toggle popover</Button>
</Popover.Target>
<Popover.Dropdown>
<Select
comboboxProps={{ withinPortal: false }}
data={[
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'angular', label: 'Angular' },
]}
placeholder="Choose your framework"
/>
</Popover.Dropdown>
</Popover>
);
}

export const NestedPopoversWorking: MantineDemo = {
type: 'code',
component: DemoWithoutIssue,
code: codeWithoutIssue,
centered: true,
};
14 changes: 14 additions & 0 deletions apps/help.mantine.dev/src/mdx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { meta as alignInputButton } from './pages/q/align-input-button.mdx';
import { meta as areMantineComponentsAccessible } from './pages/q/are-mantine-components-accessible.mdx';
import { meta as autocompleteValueLabel } from './pages/q/autocomplete-value-label.mdx';
import { meta as bodyBackground } from './pages/q/body-background.mdx';
import { meta as browserZoomsOnFocus } from './pages/q/browser-zooms-on-focus.mdx';
import { meta as canIUseMantineWithAstro } from './pages/q/can-i-use-mantine-with-astro.mdx';
import { meta as canIUseMantineWithCra } from './pages/q/can-i-use-mantine-with-cra.mdx';
import { meta as carouselMissingStyles } from './pages/q/carousel-missing-styles.mdx';
import { meta as colorSchemeColor } from './pages/q/color-scheme-color.mdx';
import { meta as comboboxTesting } from './pages/q/combobox-testing.mdx';
import { meta as customInputUseForm } from './pages/q/custom-input-use-form.mdx';
Expand Down Expand Up @@ -31,12 +33,16 @@ import { meta as lightDarkIsNotEnough } from './pages/q/light-dark-is-not-enough
import { meta as listOfStringsInUseForm } from './pages/q/list-of-strings-in-use-form.mdx';
import { meta as mantineProviderMissing } from './pages/q/mantine-provider-missing.mdx';
import { meta as multiselectValuePlaceholder } from './pages/q/multiselect-value-placeholder.mdx';
import { meta as nestedInlineStyles } from './pages/q/nested-inline-styles.mdx';
import { meta as nestedPopoverCloses } from './pages/q/nested-popover-closes.mdx';
import { meta as nextLoadFonts } from './pages/q/next-load-fonts.mdx';
import { meta as notificationsEmptyScreen } from './pages/q/notifications-empty-screen.mdx';
import { meta as notificationsMissingStyles } from './pages/q/notifications-missing-styles.mdx';
import { meta as otherLibs } from './pages/q/other-libs.mdx';
import { meta as pinchToZoomModal } from './pages/q/pinch-to-zoom-modal.mdx';
import { meta as polymorphicInPolymorphic } from './pages/q/polymorphic-in-polymorphic.mdx';
import { meta as postcssFnsInline } from './pages/q/postcss-fns-inline.mdx';
import { meta as primaryVirtualColor } from './pages/q/primary-virtual-color.mdx';
import { meta as privateCssVariables } from './pages/q/private-css-variables.mdx';
import { meta as remixLoadFonts } from './pages/q/remix-load-fonts.mdx';
import { meta as roadmap } from './pages/q/roadmap.mdx';
Expand All @@ -47,6 +53,7 @@ import { meta as serverComponents } from './pages/q/server-components.mdx';
import { meta as stylesOrder } from './pages/q/styles-order.mdx';
import { meta as tabsBorderColor } from './pages/q/tabs-border-color.mdx';
import { meta as thirdPartyStyles } from './pages/q/third-party-styles.mdx';
import { meta as transparentButtons } from './pages/q/transparent-buttons.mdx';
import { meta as viteLoadFonts } from './pages/q/vite-load-fonts.mdx';
import { meta as vueSvelteAngular } from './pages/q/vue-svelte-angular.mdx';
import { meta as whyVscodeCannotAutoimportText } from './pages/q/why-vscode-cannot-autoimport-text.mdx';
Expand All @@ -55,9 +62,11 @@ export const MDX_DATA = [
alignInputButton,
areMantineComponentsAccessible,
autocompleteValueLabel,
bodyBackground,
browserZoomsOnFocus,
canIUseMantineWithAstro,
canIUseMantineWithCra,
carouselMissingStyles,
colorSchemeColor,
comboboxTesting,
customInputUseForm,
Expand Down Expand Up @@ -85,12 +94,16 @@ export const MDX_DATA = [
listOfStringsInUseForm,
mantineProviderMissing,
multiselectValuePlaceholder,
nestedInlineStyles,
nestedPopoverCloses,
nextLoadFonts,
notificationsEmptyScreen,
notificationsMissingStyles,
otherLibs,
pinchToZoomModal,
polymorphicInPolymorphic,
postcssFnsInline,
primaryVirtualColor,
privateCssVariables,
remixLoadFonts,
roadmap,
Expand All @@ -101,6 +114,7 @@ export const MDX_DATA = [
stylesOrder,
tabsBorderColor,
thirdPartyStyles,
transparentButtons,
viteLoadFonts,
vueSvelteAngular,
whyVscodeCannotAutoimportText,
Expand Down
42 changes: 42 additions & 0 deletions apps/help.mantine.dev/src/pages/q/body-background.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Layout } from '@/layout';

export const meta = {
title: 'How can I change body background color?',
description: 'Use CSS to change body background color',
slug: 'body-background',
category: 'styles',
tags: ['body', 'html', 'global styles'],
created_at: 'September 8, 2024',
last_updated_at: 'September 8, 2024',
};

export default Layout(meta);

## Change body background with CSS

To change `body` background color you can use CSS. To do that, create `styles.css`
file in your project and import it at the root of your application:

```css
body {
background-color: #f9f9f9;
}
```

## Change body background with CSS variable

`--mantine-color-body` CSS variable is used for body background and
as background color of some components ([Modal](https://mantine.dev/core/modal/), [Paper](https://mantine.dev/core/paper/), etc.).
To override this variable, create `styles.css` file in your project and import it at the root of your application:

```scss
:root {
@mixin light {
--mantine-color-body: #f9f9f9;
}

@mixin dark {
--mantine-color-body: #333;
}
}
```
30 changes: 30 additions & 0 deletions apps/help.mantine.dev/src/pages/q/carousel-missing-styles.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Layout } from '@/layout';

export const meta = {
title: 'Why my Carousel slides are in vertical orientation?',
description: 'You forgot to import carousel styles',
slug: 'carousel-missing-styles',
category: 'styles',
tags: ['carousel', '@mantine/carousel', 'broken'],
created_at: 'September 7, 2024',
last_updated_at: 'September 7, 2024',
};

export default Layout(meta);

## Carousel component looks broken

If your [Carousel](https://mantine.dev/x/carousel/) component renders slides in vertical orientation
or has incorrect controls/indicators position, you forgot to import carousel styles.
Follow [@mantine/carousel](https://mantine.dev/x/carousel/#installation) installation
instructions to fix the issue. Import `@mantine/core` and `@mantine/carousel` styles at
the root of your application:

```tsx
import '@mantine/core/styles.css';
import '@mantine/carousel/styles.css';
```

## That's it! It works now!

Nice! 👍
99 changes: 99 additions & 0 deletions apps/help.mantine.dev/src/pages/q/nested-inline-styles.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { Layout } from '@/layout';

export const meta = {
title: 'Can I use nested inline styles with Mantine components?',
description: 'Nested styles are supported only in CSS files',
slug: 'nested-inline-styles',
category: 'styles',
tags: ['hover', 'focus', 'data-', '::selection'],
created_at: 'September 7, 2024',
last_updated_at: 'September 7, 2024',
};

export default Layout(meta);

## What are nested inline styles?

Nested inline styles are commonly used in CSS-in-JS libraries like [emotion](https://emotion.sh/).
Nested inline styles syntax looks something like this (example from [emotion documentation](https://emotion.sh/docs/css-prop#object-styles)):

```tsx
render(
<div
css={{
backgroundColor: 'hotpink',
'&:hover': {
color: 'lightgreen',
},
}}
>
This has a hotpink background.
</div>
);
```

## Styles in Mantine components

Mantine components do not support nested inline styles out of the box. The following
example will not work:

```tsx
import { Button } from '@mantine/core';

function Demo() {
return (
<Button
style={{
// ✅ This works
backgroundColor: 'hotpink',

// ❌ This does not work
'&:hover': { color: 'lightgreen' },
}}
styles={{
root: {
// ✅ This works
backgroundColor: 'hotpink',

// ❌ This does not work
'&[data-disabled]': { color: 'lightgreen' },
'&:hover': { color: 'lightgreen' },
'&:focus': { color: 'lightgreen' },
'& span': { color: 'lightgreen' },
},
}}
>
This has a hotpink background.
</Button>
);
}
```

## Why nested inline styles are not supported?

Mantine does not use CSS-in-JS library for styling – all styles are either in CSS files
or inline in the `style` attribute which does not support nested styles. Mantine does not
use CSS-in-JS to keep bundle size small, provide support for server-side rendering and
improve performance. You can learn more about performance [in the styles performance guide](https://mantine.dev/styles/styles-performance/).

## What is the alternative?

You can use nested selectors in [CSS files](https://mantine.dev/styles/css-modules/):

```scss
.button {
background-color: hotpink;

&:hover {
color: lightgreen;
}
}
```

To learn more about styles in Mantine, follow [CSS modules](https://mantine.dev/styles/css-modules/),
[PostCSS preset](https://mantine.dev/styles/postcss-preset/) and [Styles API](https://mantine.dev/styles/styles-api/) guides.

## I still want to use nested inline styles

Mantine has support for emotion. To set it up, follow [emotion installation guide](https://mantine.dev/styles/emotion/).
Note that this will increase bundle size and will affect performance.
Loading

0 comments on commit d3c2e39

Please sign in to comment.