-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce storybook into development process (#1564)
Co-authored-by: matthiashader <[email protected]> Co-authored-by: Julian Lamplmair <[email protected]>
- Loading branch information
1 parent
f5af78e
commit 4c969b5
Showing
40 changed files
with
3,965 additions
and
790 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
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,67 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import type { | ||
Config, | ||
JsonDocs, | ||
OutputTargetCustom, | ||
} from '@stencil/core/internal'; | ||
import fs from 'fs/promises'; | ||
import path from 'path'; | ||
|
||
function kebabToCamelCase(str: string): string { | ||
return str | ||
.split('-') | ||
.map((word, index) => { | ||
if (index === 0) { | ||
return word.toLowerCase(); | ||
} | ||
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); | ||
}) | ||
.join(''); | ||
} | ||
|
||
export function storybookOutputTarget(config: { | ||
dist: string; | ||
}): OutputTargetCustom { | ||
const outputTarget: OutputTargetCustom = { | ||
type: 'custom', | ||
name: 'storybook', | ||
generator: async ( | ||
{ rootDir }: Config, | ||
compilerCtx: any, | ||
buildCtx: any, | ||
docs: JsonDocs | ||
) => { | ||
const storyBookDefine = docs.components | ||
.map((component) => { | ||
return `import { defineCustomElement as ${kebabToCamelCase( | ||
component.tag | ||
)} } from '@siemens/ix/components/${component.tag}.js';`; | ||
}) | ||
.join('\n'); | ||
|
||
const callDefine = docs.components | ||
.map((component) => { | ||
return `${kebabToCamelCase(component.tag)}();`; | ||
}) | ||
.join('\n'); | ||
|
||
const storyBookDefineFile = [ | ||
`// This file is automatically generated by the Stencil output.`, | ||
`// Do not modify this file!`, | ||
storyBookDefine, | ||
callDefine, | ||
].join('\n'); | ||
|
||
fs.writeFile(path.join(config.dist), storyBookDefineFile); | ||
}, | ||
}; | ||
return outputTarget; | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.