-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c6ba80
commit 674b85b
Showing
126 changed files
with
8,681 additions
and
5,039 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"sourceType": "unambiguous", | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"chrome": 100, | ||
"safari": 15, | ||
"firefox": 91 | ||
} | ||
} | ||
], | ||
"@babel/preset-typescript", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import glob from 'fast-glob'; | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
|
||
const files = glob.sync(path.resolve(__dirname, '../src/mantine-demos/src/**/*.demos.story.tsx')); | ||
|
||
function ucFirst(string: string) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
|
||
for (const file of files) { | ||
const fileData = path.parse(file); | ||
|
||
const fileContent = fs.readFileSync(`${fileData.dir}/index.ts`, 'utf8'); | ||
const fileLines = fileContent.split('\n'); | ||
const componentName = fileData.name.split('.')[0]; | ||
|
||
const storyData: { name: string; exportName: string; key: string }[] = []; | ||
for (const fileLine of fileLines) { | ||
const exportList = fileLine.match(/export.*{([^)]+)}/)?.[1].trim(); | ||
if (exportList) { | ||
for (const exportName of exportList.split(',')) { | ||
if (exportName) { | ||
storyData.push({ | ||
name: `⭐ Demo: ${exportName.trim()}`, | ||
exportName: `Demo${ucFirst(exportName.trim())}`, | ||
key: exportName.trim(), | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
const relativePath = file.replace(`${path.resolve(__dirname, '../src/mantine-demos/src')}/`, ''); | ||
const depth = relativePath.split('/').length - 1; | ||
const depthArray = new Array(depth).fill('..'); | ||
|
||
const content = `import { Meta, StoryObj } from '@storybook/react'; | ||
import * as demos from './index'; | ||
import { renderDemo } from '${depthArray.join('/')}/render-demo'; | ||
const meta: Meta = { | ||
title: '${componentName}', | ||
}; | ||
export default meta; | ||
type Story = StoryObj; | ||
${storyData | ||
.map( | ||
(data) => `export const ${data.exportName}: Story = { | ||
name: '${data.name}', | ||
render: renderDemo(demos.${data.key}), | ||
};` | ||
) | ||
.join('\n\n')} | ||
`; | ||
|
||
fs.writeFileSync(file, content); | ||
} |
This file was deleted.
Oops, something went wrong.
96 changes: 93 additions & 3 deletions
96
src/mantine-demos/src/demos/carousel/Carousel.demos.story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,95 @@ | ||
import { storiesOf } from '@storybook/react'; | ||
import { attachDemos } from '../../attach-demos'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import * as demos from './index'; | ||
import { renderDemo } from '../../render-demo'; | ||
|
||
attachDemos(storiesOf('Carousel', module), demos); | ||
const meta: Meta = { | ||
title: 'Carousel', | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj; | ||
|
||
export const DemoUsage: Story = { | ||
name: '⭐ Demo: usage', | ||
render: renderDemo(demos.usage), | ||
}; | ||
|
||
export const DemoVertical: Story = { | ||
name: '⭐ Demo: vertical', | ||
render: renderDemo(demos.vertical), | ||
}; | ||
|
||
export const DemoIcons: Story = { | ||
name: '⭐ Demo: icons', | ||
render: renderDemo(demos.icons), | ||
}; | ||
|
||
export const DemoImages: Story = { | ||
name: '⭐ Demo: images', | ||
render: renderDemo(demos.images), | ||
}; | ||
|
||
export const DemoMultiple: Story = { | ||
name: '⭐ Demo: multiple', | ||
render: renderDemo(demos.multiple), | ||
}; | ||
|
||
export const DemoBreakpoints: Story = { | ||
name: '⭐ Demo: breakpoints', | ||
render: renderDemo(demos.breakpoints), | ||
}; | ||
|
||
export const DemoAutoplay: Story = { | ||
name: '⭐ Demo: autoplay', | ||
render: renderDemo(demos.autoplay), | ||
}; | ||
|
||
export const DemoDragFree: Story = { | ||
name: '⭐ Demo: dragFree', | ||
render: renderDemo(demos.dragFree), | ||
}; | ||
|
||
export const DemoIndicatorStyles: Story = { | ||
name: '⭐ Demo: indicatorStyles', | ||
render: renderDemo(demos.indicatorStyles), | ||
}; | ||
|
||
export const DemoControlsStyles: Story = { | ||
name: '⭐ Demo: controlsStyles', | ||
render: renderDemo(demos.controlsStyles), | ||
}; | ||
|
||
export const DemoControlsHover: Story = { | ||
name: '⭐ Demo: controlsHover', | ||
render: renderDemo(demos.controlsHover), | ||
}; | ||
|
||
export const DemoConfigurator: Story = { | ||
name: '⭐ Demo: configurator', | ||
render: renderDemo(demos.configurator), | ||
}; | ||
|
||
export const DemoProgress: Story = { | ||
name: '⭐ Demo: progress', | ||
render: renderDemo(demos.progress), | ||
}; | ||
|
||
export const DemoCards: Story = { | ||
name: '⭐ Demo: cards', | ||
render: renderDemo(demos.cards), | ||
}; | ||
|
||
export const DemoAnimationOffset: Story = { | ||
name: '⭐ Demo: animationOffset', | ||
render: renderDemo(demos.animationOffset), | ||
}; | ||
|
||
export const DemoBrokenAnimation: Story = { | ||
name: '⭐ Demo: brokenAnimation', | ||
render: renderDemo(demos.brokenAnimation), | ||
}; | ||
|
||
export const DemoStylesApi: Story = { | ||
name: '⭐ Demo: stylesApi', | ||
render: renderDemo(demos.stylesApi), | ||
}; |
Oops, something went wrong.