diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index 1412b4c4..2ab8279d 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -1,4 +1,4 @@ -name: Publish Alpha +name: Publish NPM Alpha on: push: branches: diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1097b773..48cbdaed 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -1,8 +1,9 @@ -name: Publish Docs to Github Pages +name: Publish GH Pages on: push: branches: - 'master' + - 'design-docs' jobs: build: @@ -23,6 +24,11 @@ jobs: run: npm install - name: Build docs - run: | - npm run build-docs - npm run publish-docs + run: npm run build-docs + + - name: Deploy to Github Pages 🚀 + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + ACCESS_TOKEN: ${{ secrets.GH_TOKEN }} + BRANCH: gh-pages # The branch the action should deploy to. + FOLDER: docs/.docz/dist # The folder the action should deploy. diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 931dc5d7..595b4a9a 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -1,4 +1,4 @@ -name: Publish Latest +name: Publish NPM Latest on: push: branches: diff --git a/.gitignore b/.gitignore index e3e1403f..2df5cad2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -docs/src/pages/components/**/code.mdx +docs/src/pages/components/*/code.mdx dist/ www/ diff --git a/CHANGELOG.md b/CHANGELOG.md index a52ee6bb..62a69766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,262 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 1.3.45 (2020-04-23) + +**Note:** Version bump only for package root + + + + + +## 1.3.44 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.43 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.42 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.41 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.40 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.39 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.38 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.37 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.36 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.35 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.34 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.33 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.32 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.31 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.30 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.29 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.28 (2020-04-22) + +**Note:** Version bump only for package root + + + + + +## 1.3.27 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.26 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.25 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.24 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.23 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.22 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.21 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.20 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.19 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.18 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.17 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.16 (2020-04-21) + +**Note:** Version bump only for package root + + + + + +## 1.3.15 (2020-04-20) + +**Note:** Version bump only for package root + + + + + +## 1.3.14 (2020-03-24) + +**Note:** Version bump only for package root + + + + + ## 1.3.13 (2020-03-16) **Note:** Version bump only for package root diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index f66d847d..a056608f 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -3,6 +3,262 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 1.3.45 (2020-04-23) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.44 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.43 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.42 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.41 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.40 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.39 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.38 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.37 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.36 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.35 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.34 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.33 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.32 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.31 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.30 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.29 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.28 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.27 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.26 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.25 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.24 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.23 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.22 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.21 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.20 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.19 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.18 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.17 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.16 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.15 (2020-04-20) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + +## 1.3.14 (2020-03-24) + +**Note:** Version bump only for package @accera/solar-components.core + + + + + ## 1.3.13 (2020-03-16) **Note:** Version bump only for package @accera/solar-components.core diff --git a/core/package.json b/core/package.json index 3b9f8c0e..bbeae167 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@accera/solar-components.core", - "version": "1.3.13", + "version": "1.3.45", "description": "Web Components implementation of Solar Design System", "module": "dist/index.mjs", "main": "dist/index.js", diff --git a/core/src/behaviors/controller-behavior/controller-behavior.ts b/core/src/behaviors/controller-behavior/controller-behavior.ts index c753f0c5..9dac5903 100644 --- a/core/src/behaviors/controller-behavior/controller-behavior.ts +++ b/core/src/behaviors/controller-behavior/controller-behavior.ts @@ -57,7 +57,8 @@ export class ControllerBehavior extends Compone } else { // Using delegate const element = - await delegate.createComponent>(this.component.target, props); + await delegate + .createComponent(this.component.target, props) as E & HTMLStencilControlledElement; element.controller = this.component; element._resolveDismiss = null; diff --git a/core/src/components/molecules/ac-menu/ac-menu-item/ac-menu-item.tsx b/core/src/components/molecules/ac-menu/ac-menu-item/ac-menu-item.tsx index 725404cc..0f20f356 100644 --- a/core/src/components/molecules/ac-menu/ac-menu-item/ac-menu-item.tsx +++ b/core/src/components/molecules/ac-menu/ac-menu-item/ac-menu-item.tsx @@ -24,6 +24,8 @@ export class AcMenu { @Prop() href: string; + @Prop() target: string; + @Bind handleClick() { if (this.submenu) { @@ -41,7 +43,7 @@ export class AcMenu { 'ac-menu-item--hidden': this.hidden, }} > - + diff --git a/core/src/components/molecules/ac-select/ac-select.tsx b/core/src/components/molecules/ac-select/ac-select.tsx index 23137e10..297bccd1 100644 --- a/core/src/components/molecules/ac-select/ac-select.tsx +++ b/core/src/components/molecules/ac-select/ac-select.tsx @@ -192,6 +192,7 @@ export class AcSelect implements @Watch('value') valueDidUpdate(newValue: (number | string)[] | number | string, oldValue: (number | string)[] | number | string) { + this.clearFormatSelectedText(); if (!equals(newValue, []) && !equals(newValue, oldValue)) { // Build the formatted text when the value change. this.formatSelectedText(); @@ -355,7 +356,12 @@ export class AcSelect implements } return options; } - + /** + * Clear selectedText + */ + private clearFormatSelectedText() { + this.selectedText = null; + } /** * Generate the selectedText based on the selected options. */ diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9abd3b6a..79c28dd7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,6 +3,262 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 1.3.45 (2020-04-23) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.44 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.43 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.42 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.41 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.40 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.39 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.38 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.37 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.36 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.35 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.34 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.33 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.32 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.31 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.30 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.29 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.28 (2020-04-22) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.27 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.26 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.25 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.24 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.23 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.22 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.21 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.20 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.19 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.18 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.17 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.16 (2020-04-21) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.15 (2020-04-20) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + +## 1.3.14 (2020-03-24) + +**Note:** Version bump only for package @accera/solar-components.docs + + + + + ## 1.3.13 (2020-03-16) **Note:** Version bump only for package @accera/solar-components.docs diff --git a/docs/doczrc.js b/docs/doczrc.js index 2045d85b..c48ae87c 100644 --- a/docs/doczrc.js +++ b/docs/doczrc.js @@ -1,11 +1,27 @@ -import { config } from "./theme-config.doczrc"; -import path from "path"; +import { config } from './theme-config.doczrc'; export default { + // Comment this line when using docz serve!!! base: '/solar-components/', + hashRouter: true, propsParser: false, typescript: true, codeSandbox: false, themeConfig: config, - indexHtml: './src/index.html' + public: '/public', + indexHtml: './src/index.html', + onCreateWebpackChain: config => { + config.resolve.alias + .set('@components', `src/components`); + return config + }, + // theme: 'src/theme/index', + // modifyBundlerConfig: (config) => { + // config.module.rules.push({ + // test: /\.css$/i, + // use: ['style-loader', 'css-loader'] + // }); + // + // return config + // }, } diff --git a/docs/package.json b/docs/package.json index 03789d8b..c4064cd4 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,15 +1,19 @@ { "private": true, "name": "@accera/solar-components.docs", - "version": "1.3.13", + "version": "1.3.45", "license": "MIT", "scripts": { "start": "docz dev", - "build": "docz build" + "build": "docz build", + "serve": "docz serve" }, "dependencies": { "@accera/solar-components.core": "1.3.0", + "css-loader": "^3.5.2", "docz": "1.3.2", - "docz-theme-default": "^1.2.0" + "docz-theme-default": "^1.2.0", + "react-codemirror2": "^6.0.0", + "style-loader": "^1.1.4" } } diff --git a/docs/public/admin/config.yml b/docs/public/admin/config.yml new file mode 100644 index 00000000..638e0581 --- /dev/null +++ b/docs/public/admin/config.yml @@ -0,0 +1,57 @@ +backend: + name: github + repo: accera-tech/solar-components + branch: design-docs + site_domain: condescending-bartik-296ab9.netlify.app + preview_context: "Publish GH Pages / build (push)" + commit_messages: + create: "docs: create {{slug}}" + update: "docs: update {{slug}}" + delete: "docs: delete {{slug}}" + uploadMedia: "docs: upload {{path}}" + deleteMedia: "docs: delete {{path}}" + openAuthoring: "docs: {{author-name}} {{message}}" +#locale: 'pt' +media_folder: "docs/public/images/uploads" +public_folder: "/public/images/uploads" +site_url: "https://accera-tech.github.io/solar-components/" +#publish_mode: editorial_workflow + +collections: + - name: "components" # Used in routes, e.g., /admin/collections/blog + label: "Componentes" # Used in the UI + label_singular: "Página" + preview_path: "src-pages-components-{{compid}}-{{doctype}}" + path: "{{compid}}/{{doctype}}" + folder: "docs/src/pages/components" # The path to the folder where the documents are stored + create: true # Allow users to create new documents in this collection + extension: ".mdx" + format: "frontmatter" + identifier_field: "name" + slug: "{{compid}}-{{doctype}}" # Filename template, e.g., YYYY-MM-DD-title.md + fields: # The fields for each document, usually in front matter + - {label: "Título", name: "name", widget: "string"} + - {label: "Id Component", name: "compid", widget: "string"} + - {label: "Tipo do Documento", name: "doctype", widget: "select", options: ["code", "usage", "accessibility"], default: "usage"} + - {label: "Capa", name: "cover", widget: "image", required: false} + - {label: "Rota", name: "route", widget: "string", required: false} + - {label: "Menu", name: "menu", widget: "hidden", default: "Componentes"} + - {label: "Corpo", name: "body", widget: "markdown"} + + - name: "general-docs" # Used in routes, e.g., /admin/collections/blog + label: "Documentação" # Used in the UI + label_singular: "Página" + preview_path: "src-pages-{{foldername}}-{{name}}" + path: "{{foldername}}/{{name}}" + folder: "docs/src/pages" # The path to the folder where the documents are stored + create: true # Allow users to create new documents in this collection + extension: ".mdx" + format: "frontmatter" + identifier_field: "name" + slug: "{{name}}" # Filename template, e.g., YYYY-MM-DD-title.md + fields: # The fields for each document, usually in front matter + - {label: "Título", name: "name", widget: "string"} + - {label: "Capa", name: "cover", widget: "image", required: false} + - {label: "Menu", name: "menu", widget: "string", required: false} + - {label: "Rota", name: "route", widget: "string", required: false} + - {label: "Corpo", name: "body", widget: "markdown"} diff --git a/docs/public/admin/index.html b/docs/public/admin/index.html new file mode 100644 index 00000000..ab4ac134 --- /dev/null +++ b/docs/public/admin/index.html @@ -0,0 +1,12 @@ + + + + + + Content Manager + + + + + + diff --git a/docs/public/admin/main.js b/docs/public/admin/main.js new file mode 100644 index 00000000..fef02567 --- /dev/null +++ b/docs/public/admin/main.js @@ -0,0 +1,89 @@ +class NetlifyCMS { + PREVIEW_STYLES = ` + html, body { + color: #444; + font-size: 14px; + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + } + body { + padding: 20px; + } + h1 { + margin-top: 20px; + color: #666; + font-weight: bold; + font-size: 32px; + } + img { + max-width: 100%; + } + iframe { + min-width: 100%; + height: 500px; + border: 1px solid #E6E6E6; + background: #FFFFFF; + } + `; + + get mode() { return this._mode }; + set mode(value) { + if (value === 'VIEW') { + this.toggleEditIcon.classList.replace('fa-edit', 'fa-eye'); + this.docRoot.style.display = 'none'; + this.ncRoot.style.display = ''; + } else { + this.toggleEditIcon.classList.replace('fa-eye', 'fa-edit'); + this.docRoot.style.display = ''; + this.ncRoot.style.display = 'none'; + } + this._mode = value; + }; + + constructor() { + this.toggleEditButton = document.getElementById('toggleEditButton'); + this.toggleEditIcon = document.getElementById('toggleEditIcon'); + this.docRoot = document.getElementById('root'); + this.ncRoot = document.getElementById('nc-root'); + + window.CMS.registerPreviewStyle(this.PREVIEW_STYLES, { raw: true }); + registerAdobeXDComponent(window.CMS); + registerImportsComponent(window.CMS); + this.toggleEditButton.addEventListener('click', this.toggleEdit.bind(this)); + } + + toggleEdit() { + this.mode = this.mode === 'VIEW' ? 'EDIT' : 'VIEW'; + } +} + +function registerAdobeXDComponent(CMS) { + CMS.registerEditorComponent({ + id: 'adobexd', + label: 'AdobeXD', + fields: [{name: 'url', label: 'AdobeXD Preview URL', widget: 'string'}], + pattern: /^$/, + fromBlock: match => ({ url: match[1] }), + toBlock: obj => ``, + toPreview: obj => `"`, + }); +} + +function registerImportsComponent(CMS) { + CMS.registerEditorComponent({ + id: 'imports', + label: 'Imports', + fields: [{name: 'code', label: 'Import Code', widget: 'text', default: ` +import { Playground } from 'docz'; +import { JSCodeBlock } from '@components/JSCodeBlock'; +import { AdobeXDPreview } from '@components/AdobeXDPreview'; +import { defineCustomElements } from '@accera/solar-components.core/dist/loader'; +defineCustomElements(window); +`}], + pattern: /\/\/ JSXIMPORTS\n(.+)\n\/\/ END JSXIMPORTS/gms, + fromBlock: match => ({ code: match[1] }), + toBlock: obj => `// JSXIMPORTS\n${obj.code}\n// END JSXIMPORTS`, + toPreview: obj => `
${obj.code}
`, + }); +} + +new NetlifyCMS(); diff --git a/docs/public/admin/style.css b/docs/public/admin/style.css new file mode 100644 index 00000000..c1241ab6 --- /dev/null +++ b/docs/public/admin/style.css @@ -0,0 +1,15 @@ +.app__fab-button { + position: fixed; + right: 0; + bottom: 0; + margin: 32px; + width: 50px; + height: 50px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 100%; + background: #00273c; + color: white; + box-shadow: 0 10px 10px 0 rgba(0,0,0,.25); +} diff --git a/docs/public/images/uploads/.gitkeep b/docs/public/images/uploads/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/docs/src/components/AdobeXDPreview.jsx b/docs/src/components/AdobeXDPreview.jsx new file mode 100644 index 00000000..c75f71a7 --- /dev/null +++ b/docs/src/components/AdobeXDPreview.jsx @@ -0,0 +1,15 @@ +import React from 'react'; +import styled from 'styled-components'; + +const StyledIFrame = styled('iframe')` + height: 500px; + border: 1px solid #E6E6E6; + width: 100%; + background: #FFFFFF; +`; + +export function AdobeXDPreview(props) { + return ( + + ); +} diff --git a/docs/src/components/JSCodeBlock.jsx b/docs/src/components/JSCodeBlock.jsx new file mode 100644 index 00000000..342f6389 --- /dev/null +++ b/docs/src/components/JSCodeBlock.jsx @@ -0,0 +1,79 @@ +import React from 'react'; +import styled from 'styled-components'; +import { Controlled as BaseCodeMirror } from 'react-codemirror2'; +import 'codemirror/mode/javascript/javascript'; +import 'codemirror/addon/edit/matchbrackets'; + +import { theme } from './codemirrorTheme'; + +const defaultOptions = { + tabSize: 2, + lineNumbers: true, + lineWrapping: true, + autoCloseTags: true, + theme: 'docz-light', +}; + +const Wrapper = styled('div')` + position: relative; + border: 1px solid #E6E6E6; + margin-bottom: 30px; +`; + +const CodeMirror = styled(BaseCodeMirror)` + ${theme}; + position: relative; + flex: 1; + .CodeMirror { + max-width: 100%; + height: 100%; + } + .CodeMirror-gutters { + left: 1px !important; + } + .CodeMirror-lines { + padding: 10px 0; + box-sizing: content-box; + } + .CodeMirror-line { + padding: 0 10px; + } + .CodeMirror-linenumber { + padding: 0 7px 0 5px; + } + pre { + font-family: "Inconsolata",monospace; + font-size: 1em; + line-height: 1.8; + } +`; + +export class JSCodeBlock extends React.Component { + state = { code: this.props.children, err: null }; + executed = false; + + componentDidMount() { + // @TODO: Find a generic way to know if the target playground is initialized. + document.addEventListener('stencil_componentDidLoad', () => this.run()); + } + + run() { + if (!this.executed) { + try { + eval(`(function() {${this.state.code}})()`); + } catch(err) { + this.setState({ ...this.state, err: err.toString() }) + } + this.executed = true; + } + } + + render() { + return ( + + {this.state.err &&
{this.state.err}
} + +
+ ); + } +} diff --git a/docs/src/components/codemirrorTheme.js b/docs/src/components/codemirrorTheme.js new file mode 100644 index 00000000..fced9f49 --- /dev/null +++ b/docs/src/components/codemirrorTheme.js @@ -0,0 +1,107 @@ +import { css } from 'styled-components' + +export const theme = css` + .cm-s-docz-light.CodeMirror { + border-radius: 0; + background: #fbfcfd; + color: #24292e; + } + + .cm-s-docz-light .CodeMirror-gutters { + background: #fbfcfd; + border-right-width: 0; + border-radius: 0; + } + + .cm-s-docz-light .CodeMirror-guttermarker { + color: white; + } + + .cm-s-docz-light .CodeMirror-guttermarker-subtle { + color: #d0d0d0; + } + + .cm-s-docz-light .CodeMirror-linenumber { + color: #959da5; + background: #fbfcfd; + } + + .cm-s-docz-light .CodeMirror-cursor { + border-left: 1px solid #24292e; + } + + .cm-s-docz-light div.CodeMirror-selected, + .cm-s-docz-light .CodeMirror-line::selection, + .cm-s-docz-light .CodeMirror-line > span::selection, + .cm-s-docz-light .CodeMirror-line > span > span::selection, + .cm-s-docz-light .CodeMirror-line::-moz-selection, + .cm-s-docz-light .CodeMirror-line > span::-moz-selection, + .cm-s-docz-light .CodeMirror-line > span > span::-moz-selection { + background: #c8c8fa; + } + + .cm-s-docz-light .CodeMirror-activeline-background { + background: #fafbfc; + } + + .cm-s-docz-light .CodeMirror-matchingbracket { + text-decoration: underline; + color: #949495 !important; + } + + .cm-s-docz-light .CodeMirror-lines { + background: #fbfcfd; + } + + .cm-s-docz-light .cm-comment { + color: #6a737d; + } + + .cm-s-docz-light .cm-tag, + .cm-s-docz-light .cm-bracket { + color: #d73a49; + } + + .cm-s-docz-light .cm-constant { + color: #005cc5; + } + + .cm-s-docz-light .cm-entity { + font-weight: normal; + font-style: normal; + text-decoration: none; + color: #6f42c1; + } + + .cm-s-docz-light .cm-keyword { + font-weight: normal; + font-style: normal; + text-decoration: none; + color: #d73a49; + } + + .cm-s-docz-light .cm-storage { + color: #d73a49; + } + + .cm-s-docz-light .cm-string { + font-weight: normal; + font-style: normal; + text-decoration: none; + color: #005cc5; + } + + .cm-s-docz-light .cm-support { + font-weight: normal; + font-style: normal; + text-decoration: none; + color: #005cc5; + } + + .cm-s-docz-light .cm-variable { + font-weight: normal; + font-style: normal; + text-decoration: none; + color: #e36209; + } +`; diff --git a/docs/src/index.html b/docs/src/index.html index e95be6b7..e9ff9e8d 100644 --- a/docs/src/index.html +++ b/docs/src/index.html @@ -8,10 +8,18 @@ {{ title }} + + {{ head }}
+
+ + + {{ footer }} + + diff --git a/docs/src/pages/components/ac-select/usage.mdx b/docs/src/pages/components/ac-select/usage.mdx new file mode 100644 index 00000000..81c12b70 --- /dev/null +++ b/docs/src/pages/components/ac-select/usage.mdx @@ -0,0 +1,17 @@ +--- +name: Example +compid: example +doctype: usage +menu: Componentes +--- + + import { Playground } from 'docz'; + import { JSCodeBlock } from '@components/JSCodeBlock'; + import { AdobeXDPreview } from '@components/AdobeXDPreview'; + import { defineCustomElements } from '@accera/solar-components.core/dist/loader'; + defineCustomElements(window); + + +# Example with Adobe XD + + \ No newline at end of file diff --git a/docs/src/index.mdx b/docs/src/pages/index.mdx similarity index 100% rename from docs/src/index.mdx rename to docs/src/pages/index.mdx diff --git a/docs/src/theme/index.html b/docs/src/theme/index.html new file mode 100644 index 00000000..31544f3a --- /dev/null +++ b/docs/src/theme/index.html @@ -0,0 +1,59 @@ + + + + + + + + {{ title }} + + + + {{ head }} + + +
+ + + + +{{ footer }} + + + + diff --git a/gulpfile.js b/gulpfile.js index 9177da5f..39408ce6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,14 +1,14 @@ -const { watch, src, dest } = require('gulp'); +const { watch, src, dest, series } = require('gulp'); const inject = require('gulp-inject-string'); const flatten = require('gulp-flatten'); const rename = require('gulp-rename'); const replace = require('gulp-replace'); -const ghpages = require('gh-pages'); const docsDest = 'docs/src/pages/components'; const mdxSrcGlob = 'core/src/**/*.{md,mdx}'; const mdxLoader = -`import { Playground } from 'docz'; + `import { Playground } from 'docz'; +import { JSCodeBlock } from '@components/JSCodeBlock'; import { defineCustomElements } from '@accera/solar-components.core/dist/loader'; defineCustomElements(window); @@ -17,37 +17,47 @@ defineCustomElements(window); /** * Copy all mdx files to docs package. * @param glob The glob rule to run. + * @param [customDest] The dest path. * @returns {*} */ -function docsCopy(glob) { +function docsCopy(glob, customDest) { return src(glob) .pipe(replace( /^````html(.+?(?=````))````$/gms, '$1', { logs: { enabled: false } }) ) + .pipe(replace( + /^````js(.+?(?=````))````$/gms, + '{`$1`}', + { logs: { enabled: false } }) + ) .pipe(inject.after('\n---\n', mdxLoader)) .pipe(flatten({ includeParents: -1 })) .pipe(rename(path => { path.basename = 'code'; path.extname = '.mdx' })) - .pipe(dest(docsDest)); + .pipe(dest(customDest || docsDest)); } -function docsPublish() { - return new Promise(res => { - ghpages.publish('docs/.docz/dist', res); - }); -} - -exports.docsCopy = () => docsCopy(mdxSrcGlob); -exports.docsPublish = docsPublish; -exports.docsWatch = () => { +function docsWatch() { const watcher = watch(mdxSrcGlob); - watcher.on('change', path => docsCopy(path)); - watcher.on('add', path => docsCopy(path)); + watcher.on('change', docsCopyFromPath); + watcher.on('add', docsCopyFromPath); return watcher; -}; +} + +function docsCopyAll() { + return docsCopy(mdxSrcGlob); +} + +function docsCopyFromPath(path) { + const splittedPath = path.split('/'); + return docsCopy(path, docsDest + '/', splittedPath[splittedPath.length - 2]) +} + +exports.docsCopy = docsCopyAll; +exports.docsWatch = series(docsCopyAll, docsWatch); diff --git a/lerna.json b/lerna.json index b01f26c6..6d522db1 100644 --- a/lerna.json +++ b/lerna.json @@ -3,7 +3,7 @@ "core", "docs" ], - "version": "1.3.13", + "version": "1.3.45", "command": { "publish": { "message": "chore(release): publish %v" diff --git a/package.json b/package.json index ffc8bf25..ef01e4a9 100644 --- a/package.json +++ b/package.json @@ -4,17 +4,15 @@ "scripts": { "publish-latest": "lerna publish -y --force-publish=* --conventional-commits --create-release github", "publish-alpha": "lerna publish prerelease -y --force-publish=* --no-push --no-git-tag-version --dist-tag alpha", - "postinstall": "lerna bootstrap --force-local", + "postinstall": "lerna bootstrap --force-local --no-ci", "start": "concurrently -n gulp,stencil,docz \"npx gulp docsWatch\" \"npm start --prefix core\" \"npm start --prefix docs\"", - "build-docs": "npm run build --prefix core && npx gulp docsCopy && npm run build --prefix docs", - "publish-docs": "npx gulp docsPublish" + "build-docs": "npm run build --prefix core && npx gulp docsCopy && npm run build --prefix docs" }, "devDependencies": { "@commitlint/cli": "^8.3.5", "@commitlint/config-conventional": "^8.3.4", "concurrently": "^5.0.2", "conventional-changelog": "^3.1.3", - "gh-pages": "^2.2.0", "gulp": "^4.0.2", "gulp-flatten": "^0.4.0", "gulp-inject-string": "^1.1.2",