Skip to content

Commit

Permalink
feat(core): add sage-icon library to core lib
Browse files Browse the repository at this point in the history
chore(storybook): merge icon and core docs.json files

This is needed to have a single source to list out

the properties for the components using argsTable function
  • Loading branch information
ju-Skinner committed Jan 30, 2023
1 parent f58a563 commit f318d2e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 4 deletions.
1 change: 0 additions & 1 deletion libs/core/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ src/components.d.ts
**/*.spec.ts
**/*.spec.tsx
**/*.e2e.ts
**/*.d.ts
**/*.stories.*
1 change: 1 addition & 0 deletions libs/core/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": ["plugin:@stencil/recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json"]
},
Expand Down
10 changes: 10 additions & 0 deletions libs/core/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { extractArgTypes, extractComponentDescription, setStencilDocJson } from '@pxtrn/storybook-addon-docs-stencil';

import docsJson from '../dist/docs.json';
import iconDocsJson from '../../icons/dist/docs.json';

/*
*
* Merge the Icon docs.json with core docs.json file
* This is needed to list out the Properties in the argsTable
*
*/
const combinedDocsJson = [...new Set([...docsJson.components, ...iconDocsJson.components])];
docsJson.components = combinedDocsJson

if (docsJson) { setStencilDocJson(docsJson) }

Expand Down
6 changes: 4 additions & 2 deletions libs/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"collection:main": "dist/collection/index.js",
"unpkg": "dist/core/core.esm.js",
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
"registry": "https://npm.pkg.github.com/",
"directory": "dist"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -49,7 +50,8 @@
"test.watch": "stencil test --spec --e2e --watchAll"
},
"dependencies": {
"@stencil/core": "^2.18.0"
"@stencil/core": "^2.18.0",
"@sage/icons": "*"
},
"devDependencies": {
"@babel/core": "^7.19.3",
Expand Down
20 changes: 20 additions & 0 deletions libs/core/src/components/sage-icon/sage-icon.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import {html, render} from 'lit-html';

import { extractArgTypes } from '@pxtrn/storybook-addon-docs-stencil';

<Meta title="webcomponents/Icon" component="sage-icon" argTypes={extractArgTypes('sage-icon')} />

export const Template = (args) => html`<sage-icon name=${args.name} size=${args.size}></sage-icon>`;

# Sage icon

<Canvas>
<Story name="Default" args={{name: "upload"}}>
{Template.bind()}
</Story>
</Canvas>

## Properties

<ArgsTable of="sage-icon" />
1 change: 1 addition & 0 deletions libs/core/src/global/sage-ui-global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@sage/icons';
2 changes: 1 addition & 1 deletion libs/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './components';
import '@sage/icons';
17 changes: 17 additions & 0 deletions libs/core/src/interface.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Components as SageIconsComponents, JSX as SageIconsJSX } from '@sage/icons';

export * from './components';
export * from './index';


declare module './components' {
export namespace Components {
export type SageIcon = SageIconsComponents.SageIcon;
}
}

declare module './components' {
export namespace JSX {
export type SageIcon = SageIconsJSX.SageIcon;
}
}

0 comments on commit f318d2e

Please sign in to comment.