Skip to content

Commit

Permalink
feat: update ui kit package and fix windows script usage
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavshn committed Aug 6, 2022
1 parent 7893512 commit 4b5591a
Show file tree
Hide file tree
Showing 14 changed files with 256 additions and 52 deletions.
3 changes: 0 additions & 3 deletions bin/postinstall.sh

This file was deleted.

93 changes: 93 additions & 0 deletions bin/ui-kit/component-docs.cjs
@@ -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')
);
}
17 changes: 17 additions & 0 deletions bin/ui-kit/utils.cjs
@@ -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 };
29 changes: 29 additions & 0 deletions docs/angular-ui-kit/reference/interfaces/PollObject.md
@@ -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`
2 changes: 1 addition & 1 deletion docs/angular-ui-kit/reference/interfaces/States.md
Expand Up @@ -80,7 +80,7 @@ ___

### meeting

`Optional` **meeting**: ``"idle"`` \| ``"setup"`` \| ``"joined"`` \| ``"ended"``
`Optional` **meeting**: ``"idle"`` \| ``"setup"`` \| ``"joined"`` \| ``"ended"`` \| ``"waiting"``

___

Expand Down
11 changes: 11 additions & 0 deletions docs/angular-ui-kit/reference/reference.md
Expand Up @@ -7,6 +7,7 @@ custom_edit_url: null
## Interfaces

- [Notification](interfaces/Notification.md)
- [PollObject](interfaces/PollObject.md)
- [States](interfaces/States.md)
- [UIConfig](interfaces/UIConfig.md)
- [UserPreferences](interfaces/UserPreferences.md)
Expand Down Expand Up @@ -80,6 +81,7 @@ ___
| `attach` | `string` |
| `call_end` | `string` |
| `chat` | `string` |
| `checkmark` | `string` |
| `chevron_down` | `string` |
| `chevron_left` | `string` |
| `chevron_right` | `string` |
Expand Down Expand Up @@ -113,6 +115,7 @@ ___
| `share_screen_stop` | `string` |
| `speaker` | `string` |
| `spinner` | `string` |
| `spotlight` | `string` |
| `stop_recording` | `string` |
| `subtract` | `string` |
| `vertical_scroll` | `string` |
Expand Down Expand Up @@ -141,13 +144,16 @@ Default language dictionary
| `connection` | `string` |
| `dismiss` | `string` |
| `end_meeting_for_all` | `string` |
| `full_screen` | `string` |
| `full_screen.exit` | `string` |
| `leave` | `string` |
| `leave_confirmation` | `string` |
| `left_meeting` | `string` |
| `mic_off` | `string` |
| `mic_on` | `string` |
| `page` | `string` |
| `participants` | `string` |
| `perm.sys_denied.message` | `string` |
| `perm_browser_denied` | `string` |
| `perm_denied_text` | `string` |
| `perm_denied_title` | `string` |
Expand All @@ -160,6 +166,11 @@ Default language dictionary
| `video` | `string` |
| `video_off` | `string` |
| `video_on` | `string` |
| `waitlist.accept_all` | `string` |
| `waitlist.accept_request` | `string` |
| `waitlist.body_text` | `string` |
| `waitlist.deny_request` | `string` |
| `waitlist.header_title` | `string` |

## Functions

Expand Down
29 changes: 29 additions & 0 deletions docs/react-ui-kit/reference/interfaces/PollObject.md
@@ -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`
2 changes: 1 addition & 1 deletion docs/react-ui-kit/reference/interfaces/States.md
Expand Up @@ -80,7 +80,7 @@ ___

### meeting

`Optional` **meeting**: ``"idle"`` \| ``"setup"`` \| ``"joined"`` \| ``"ended"``
`Optional` **meeting**: ``"idle"`` \| ``"setup"`` \| ``"joined"`` \| ``"ended"`` \| ``"waiting"``

___

Expand Down
11 changes: 11 additions & 0 deletions docs/react-ui-kit/reference/reference.md
Expand Up @@ -7,6 +7,7 @@ custom_edit_url: null
## Interfaces

- [Notification](interfaces/Notification.md)
- [PollObject](interfaces/PollObject.md)
- [States](interfaces/States.md)
- [UIConfig](interfaces/UIConfig.md)
- [UserPreferences](interfaces/UserPreferences.md)
Expand Down Expand Up @@ -80,6 +81,7 @@ ___
| `attach` | `string` |
| `call_end` | `string` |
| `chat` | `string` |
| `checkmark` | `string` |
| `chevron_down` | `string` |
| `chevron_left` | `string` |
| `chevron_right` | `string` |
Expand Down Expand Up @@ -113,6 +115,7 @@ ___
| `share_screen_stop` | `string` |
| `speaker` | `string` |
| `spinner` | `string` |
| `spotlight` | `string` |
| `stop_recording` | `string` |
| `subtract` | `string` |
| `vertical_scroll` | `string` |
Expand Down Expand Up @@ -141,13 +144,16 @@ Default language dictionary
| `connection` | `string` |
| `dismiss` | `string` |
| `end_meeting_for_all` | `string` |
| `full_screen` | `string` |
| `full_screen.exit` | `string` |
| `leave` | `string` |
| `leave_confirmation` | `string` |
| `left_meeting` | `string` |
| `mic_off` | `string` |
| `mic_on` | `string` |
| `page` | `string` |
| `participants` | `string` |
| `perm.sys_denied.message` | `string` |
| `perm_browser_denied` | `string` |
| `perm_denied_text` | `string` |
| `perm_denied_title` | `string` |
Expand All @@ -160,6 +166,11 @@ Default language dictionary
| `video` | `string` |
| `video_off` | `string` |
| `video_on` | `string` |
| `waitlist.accept_all` | `string` |
| `waitlist.accept_request` | `string` |
| `waitlist.body_text` | `string` |
| `waitlist.deny_request` | `string` |
| `waitlist.header_title` | `string` |

## Functions

Expand Down
29 changes: 29 additions & 0 deletions docs/ui-kit/reference/interfaces/PollObject.md
@@ -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`
2 changes: 1 addition & 1 deletion docs/ui-kit/reference/interfaces/States.md
Expand Up @@ -80,7 +80,7 @@ ___

### meeting

`Optional` **meeting**: ``"idle"`` \| ``"setup"`` \| ``"joined"`` \| ``"ended"``
`Optional` **meeting**: ``"idle"`` \| ``"setup"`` \| ``"joined"`` \| ``"ended"`` \| ``"waiting"``

___

Expand Down
11 changes: 11 additions & 0 deletions docs/ui-kit/reference/reference.md
Expand Up @@ -7,6 +7,7 @@ custom_edit_url: null
## Interfaces

- [Notification](interfaces/Notification.md)
- [PollObject](interfaces/PollObject.md)
- [States](interfaces/States.md)
- [UIConfig](interfaces/UIConfig.md)
- [UserPreferences](interfaces/UserPreferences.md)
Expand Down Expand Up @@ -80,6 +81,7 @@ ___
| `attach` | `string` |
| `call_end` | `string` |
| `chat` | `string` |
| `checkmark` | `string` |
| `chevron_down` | `string` |
| `chevron_left` | `string` |
| `chevron_right` | `string` |
Expand Down Expand Up @@ -113,6 +115,7 @@ ___
| `share_screen_stop` | `string` |
| `speaker` | `string` |
| `spinner` | `string` |
| `spotlight` | `string` |
| `stop_recording` | `string` |
| `subtract` | `string` |
| `vertical_scroll` | `string` |
Expand Down Expand Up @@ -141,13 +144,16 @@ Default language dictionary
| `connection` | `string` |
| `dismiss` | `string` |
| `end_meeting_for_all` | `string` |
| `full_screen` | `string` |
| `full_screen.exit` | `string` |
| `leave` | `string` |
| `leave_confirmation` | `string` |
| `left_meeting` | `string` |
| `mic_off` | `string` |
| `mic_on` | `string` |
| `page` | `string` |
| `participants` | `string` |
| `perm.sys_denied.message` | `string` |
| `perm_browser_denied` | `string` |
| `perm_denied_text` | `string` |
| `perm_denied_title` | `string` |
Expand All @@ -160,6 +166,11 @@ Default language dictionary
| `video` | `string` |
| `video_off` | `string` |
| `video_on` | `string` |
| `waitlist.accept_all` | `string` |
| `waitlist.accept_request` | `string` |
| `waitlist.body_text` | `string` |
| `waitlist.deny_request` | `string` |
| `waitlist.header_title` | `string` |

## Functions

Expand Down

0 comments on commit 4b5591a

Please sign in to comment.