Skip to content

Commit

Permalink
[docs] Migrate styles api to @mantine/styles-api
Browse files Browse the repository at this point in the history
  • Loading branch information
rtivital committed Jan 31, 2022
1 parent bf9184e commit 0feee6d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 44 deletions.
7 changes: 2 additions & 5 deletions docs/src/components/HomePage/Customize/Customize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from 'gatsby';
import { ArrowRightIcon } from '@modulz/radix-icons';
import { Text, SimpleGrid, Slider, Button } from '@mantine/core';
import { Prism } from '@mantine/prism';
import * as CORE_STYLES_API from '@mantine/core/src/styles.api';
import { Slider as SliderStylesApi } from '@mantine/styles-api';
import DataTable from '../../MdxPage/MdxProvider/DataTable/DataTable';
import { PageSection } from '../PageSection/PageSection';

Expand Down Expand Up @@ -50,10 +50,7 @@ export function Customize() {

<DataTable
head={['Name', 'Description']}
data={Object.keys(CORE_STYLES_API.Slider).map((name) => [
name,
CORE_STYLES_API.Slider[name],
])}
data={Object.keys(SliderStylesApi).map((name) => [name, SliderStylesApi[name]])}
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import React from 'react';
import { Table, Title, Text } from '@mantine/core';
import { Prism } from '@mantine/prism';
import * as CORE_STYLES_API from '@mantine/core/src/styles.api';
import * as PRISM_STYLES_API from '@mantine/prism/src/styles.api';
import * as DATES_STYLES_API from '@mantine/dates/src/styles.api';
import * as RTE_STYLES_API from '@mantine/rte/src/styles.api';
import * as DROPZONE_STYLES_API from '@mantine/dropzone/src/styles.api';
import * as STYLES_API from '@mantine/styles-api';
import { generateStylesCode, generateClassNamesCode } from '../generate-styles-code';
import useStyles from './StylesApiItem.styles';

const STYLES_API = {
...CORE_STYLES_API,
...PRISM_STYLES_API,
...DATES_STYLES_API,
...RTE_STYLES_API,
...DROPZONE_STYLES_API,
};

interface StylesApiItemProps {
component: string;
}
Expand Down
47 changes: 24 additions & 23 deletions docs/src/demos/hooks/use-form/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import React from 'react';
import { AuthenticationForm } from '@mantine/core/demos';
import { useMantineTheme } from '@mantine/core';
import { CodeDemo } from '@mantine/ds';
// import React from 'react';
// import { AuthenticationForm } from '@mantine/core/demos';
// import { useMantineTheme } from '@mantine/core';
// import { CodeDemo } from '@mantine/ds';

// @ts-ignore
// eslint-disable-next-line import/no-webpack-loader-syntax
import code from '!!raw-loader!../../../../src/mantine-core/demos/AuthenticationForm/AuthenticationForm';
// import code from '!!raw-loader!../../../../src/mantine-core/demos/AuthenticationForm/AuthenticationForm';

export function UseFormAuthDemo({ toggle = false }: { toggle: boolean }) {
const theme = useMantineTheme();
export function UseFormAuthDemo() {
// const theme = useMantineTheme();
return null;

return (
<CodeDemo
code={code.replace('../../src', '@mantine/core')}
language="tsx"
toggle={toggle}
demoBackground={theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.colors.gray[0]}
>
<div style={{ maxWidth: 400, margin: 'auto' }}>
<AuthenticationForm
style={{
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
}}
/>
</div>
</CodeDemo>
);
// return (
// <CodeDemo
// code={code.replace('../../src', '@mantine/core')}
// language="tsx"
// toggle={toggle}
// demoBackground={theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.colors.gray[0]}
// >
// <div style={{ maxWidth: 400, margin: 'auto' }}>
// <AuthenticationForm
// style={{
// backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
// }}
// />
// </div>
// </CodeDemo>
// );
}
6 changes: 3 additions & 3 deletions docs/src/docs/theming/styles-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ order: 4

import { providerStyles } from '@docs/demos';
import { ButtonDemos, SliderDemos, TabsDemos, AccordionDemos, CalendarDemos } from '@mantine/demos';
import * as CORE_STYLES_API from '@mantine/core/src/styles.api';
import { Slider as SliderStylesApi } from '@mantine/styles-api';

# Styles API

Expand All @@ -28,10 +28,10 @@ styles names table. Name column will tell you how to target specific element in

<DataTable
head={['Name', 'Static selector', 'Description']}
data={Object.keys(CORE_STYLES_API.Slider).map((name) => [
data={Object.keys(SliderStylesApi).map((name) => [
name,
`.mantine-slider-${name}`,
CORE_STYLES_API.Slider[name],
SliderStylesApi[name],
])}
/>

Expand Down
8 changes: 8 additions & 0 deletions src/mantine-styles-api/src/PasswordInput.styles-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { PasswordInputStylesNames } from '@mantine/core';
import { TextInput } from './TextInput.styles-api';

export const PasswordInput: Record<PasswordInputStylesNames, string> = {
...TextInput,
visibilityToggle: 'Visibility toggle button',
innerInput: 'Actual input element',
};

0 comments on commit 0feee6d

Please sign in to comment.