Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update ui kit package and fix windows script usage
- Loading branch information
1 parent
7893512
commit 4b5591a
Showing
14 changed files
with
256 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,93 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const { writeMDXFile } = require('./utils.cjs'); | ||
const { pascalCase } = require('pascal-case'); | ||
|
||
const { | ||
components, | ||
} = require('@dytesdk/ui-kit/dist/docs/docs-components.json'); | ||
|
||
/** @typedef {import('@dytesdk/ui-kit/dist/docs/docs-components').JsonDocsComponent} Component */ | ||
|
||
const basePaths = { | ||
core: 'docs/ui-kit/components', | ||
react: 'docs/react-ui-kit/components', | ||
angular: 'docs/angular-ui-kit/components', | ||
}; | ||
|
||
/** | ||
* | ||
* @param {Component} component | ||
* @param {'core' | 'react' | 'angular' | 'vue'} framework | ||
* @returns | ||
*/ | ||
function generateFile(component, framework = 'core') { | ||
const { tag, docs, props, usage } = component; | ||
|
||
function getFrontmatter() { | ||
const path = `/static/ui-kit/1.x.x/components/${tag}.svg`; | ||
if (fs.existsSync(`static${path}`)) { | ||
return ['---', `image: ${path}`, '---']; | ||
} | ||
return []; | ||
} | ||
|
||
function getTitle() { | ||
let title = tag; | ||
|
||
if (framework === 'react') { | ||
title = pascalCase(tag); | ||
} | ||
|
||
return title; | ||
} | ||
|
||
function getExample() { | ||
let docName = 'html-example'; | ||
|
||
if (framework === 'react') { | ||
docName = 'react-example'; | ||
} else if (framework === 'angular') { | ||
docName = 'angular-example'; | ||
} else if (framework === 'vue') { | ||
docName = 'vue-example'; | ||
} | ||
|
||
const exampleCode = usage[docName]; | ||
|
||
return exampleCode ? [exampleCode, ''] : []; | ||
} | ||
|
||
const text = [ | ||
...getFrontmatter(), | ||
'', | ||
`# ${getTitle()}`, | ||
'', | ||
docs, | ||
'\n', | ||
...getExample(), | ||
...(props.length > 0 ? [`## Props`, `<PropsTable of="${tag}" />`] : []), | ||
'', | ||
] | ||
.filter((line) => line) | ||
.join('\n'); | ||
|
||
return text; | ||
} | ||
|
||
for (const component of components) { | ||
const { tag } = component; | ||
|
||
writeMDXFile(`${basePaths.core}/${tag}.mdx`, generateFile(component)); | ||
|
||
writeMDXFile( | ||
`${basePaths.react}/${tag}.mdx`, | ||
generateFile(component, 'react') | ||
); | ||
|
||
writeMDXFile( | ||
`${basePaths.angular}/${tag}.mdx`, | ||
generateFile(component, 'angular') | ||
); | ||
} |
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,17 @@ | ||
const fs = require('fs'); | ||
const prettier = require('prettier'); | ||
const { prettier: prettierConfig } = require('../../package.json'); | ||
|
||
/** | ||
* Writes to a file after text is formatted as MDX | ||
* @param {string} path | ||
* @returns | ||
*/ | ||
function writeMDXFile(path, text) { | ||
return fs.writeFileSync( | ||
path, | ||
prettier.format(text, { ...prettierConfig, parser: 'mdx' }) | ||
); | ||
} | ||
|
||
module.exports = { writeMDXFile }; |
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,29 @@ | ||
--- | ||
id: "PollObject" | ||
title: "Interface: PollObject" | ||
custom_edit_url: null | ||
--- | ||
|
||
## Properties | ||
|
||
### anonymous | ||
|
||
• **anonymous**: `boolean` | ||
|
||
___ | ||
|
||
### hideVotes | ||
|
||
• **hideVotes**: `boolean` | ||
|
||
___ | ||
|
||
### options | ||
|
||
• **options**: `string`[] | ||
|
||
___ | ||
|
||
### question | ||
|
||
• **question**: `string` |
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,29 @@ | ||
--- | ||
id: "PollObject" | ||
title: "Interface: PollObject" | ||
custom_edit_url: null | ||
--- | ||
|
||
## Properties | ||
|
||
### anonymous | ||
|
||
• **anonymous**: `boolean` | ||
|
||
___ | ||
|
||
### hideVotes | ||
|
||
• **hideVotes**: `boolean` | ||
|
||
___ | ||
|
||
### options | ||
|
||
• **options**: `string`[] | ||
|
||
___ | ||
|
||
### question | ||
|
||
• **question**: `string` |
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,29 @@ | ||
--- | ||
id: "PollObject" | ||
title: "Interface: PollObject" | ||
custom_edit_url: null | ||
--- | ||
|
||
## Properties | ||
|
||
### anonymous | ||
|
||
• **anonymous**: `boolean` | ||
|
||
___ | ||
|
||
### hideVotes | ||
|
||
• **hideVotes**: `boolean` | ||
|
||
___ | ||
|
||
### options | ||
|
||
• **options**: `string`[] | ||
|
||
___ | ||
|
||
### question | ||
|
||
• **question**: `string` |
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
Oops, something went wrong.