Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix prettier
  • Loading branch information
tobiasdiez committed Oct 13, 2023
commit aaa04aa24f50330b0c75b93ddcc360e7f05128fa
2 changes: 1 addition & 1 deletion examples/vite/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
18 changes: 15 additions & 3 deletions examples/vite/src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,22 @@ body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const FilledForm: Story = {
// 👇 Assert DOM structure
await expect(
canvas.getByText(
'Everything is perfect. Your account is ready and we should probably get you started!'
)
'Everything is perfect. Your account is ready and we should probably get you started!',
),
).toBeInTheDocument()
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ async function playFunction({ canvasElement }) {
// 👇 Assert DOM structure
await expect(
canvas.getByText(
'Everything is perfect. Your account is ready and we should probably get you started!'
)
'Everything is perfect. Your account is ready and we should probably get you started!',
),
).toBeInTheDocument()
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion playground/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
4 changes: 2 additions & 2 deletions src/core/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { toId } from '@storybook/csf'

export async function indexer(
fileName: string,
options: IndexerOptions
options: IndexerOptions,
): Promise<IndexedCSFFile> {
const code = (await fs.readFile(fileName, { encoding: 'utf-8' })).toString()
return indexerCode(code, options)
}

export function indexerCode(
code: string,
{ makeTitle }: IndexerOptions
{ makeTitle }: IndexerOptions,
): IndexedCSFFile {
const { meta, stories, docs } = parse(code)
const indexedStories: IndexedStory[] = stories
Expand Down
6 changes: 3 additions & 3 deletions src/core/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function parse(code: string) {
const resolvedScript = resolveScript(descriptor)
const { meta, stories } = parseTemplate(descriptor.template.content)
const docsBlock = descriptor.customBlocks?.find(
(block) => block.type === 'docs'
(block) => block.type === 'docs',
)
const docs = docsBlock?.content.trim()
return {
Expand Down Expand Up @@ -86,7 +86,7 @@ function parseTemplate(content: string): {
const storyTemplate = parseSFC(
story.loc.source
.replace(/<Story/, '<template')
.replace(/<\/Story>/, '</template>')
.replace(/<\/Story>/, '</template>'),
).descriptor.template?.content
if (storyTemplate === undefined)
throw new Error('No template found in Story')
Expand Down Expand Up @@ -138,7 +138,7 @@ function extractProp(node: ElementNode, name: string) {
(prop.name === 'bind' &&
prop.type === DIRECTIVE &&
prop.arg?.type === SIMPLE_EXPRESSION &&
prop.arg?.content === name)
prop.arg?.content === name),
)
}
}
8 changes: 4 additions & 4 deletions src/core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function transformTemplate(
stories,
docs,
}: { meta: ParsedMeta; stories: ParsedStory[]; docs?: string },
resolvedScript?: SFCScriptBlock
resolvedScript?: SFCScriptBlock,
) {
let result = generateDefaultImport(meta, docs)
for (const story of stories) {
Expand All @@ -103,7 +103,7 @@ async function transformTemplate(

function generateDefaultImport(
{ title, component }: ParsedMeta,
docs?: string
docs?: string,
) {
return `export default {
${title ? `title: '${title}',` : ''}
Expand All @@ -118,7 +118,7 @@ function generateDefaultImport(

function generateStoryImport(
{ id, title, play, template }: ParsedStory,
resolvedScript?: SFCScriptBlock
resolvedScript?: SFCScriptBlock,
) {
const { code } = compileTemplate({
source: template.trim(),
Expand All @@ -137,7 +137,7 @@ function generateStoryImport(

const renderFunction = code.replace(
'export function render',
`function render${id}`
`function render${id}`,
)

// Each named export is a story, has to return a Vue ComponentOptionsBase
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('transform', () => {
it('throws error if story does not have a title', async () => {
const code = '<template><Stories><Story>hello</Story></Stories></template>'
await expect(() =>
transform(code)
transform(code),
).rejects.toThrowErrorMatchingInlineSnapshot('"Story is missing a title"')
})
it('extracts component from Stories', async () => {
Expand Down