diff --git a/.size-snapshot.json b/.size-snapshot.json index 8cd0d06c..5ca02bb9 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -38,9 +38,9 @@ } }, "dist/index.cjs.js": { - "bundled": 77303, - "minified": 53258, - "gzipped": 9105 + "bundled": 81274, + "minified": 57910, + "gzipped": 10087 }, "dist/rbx.esm.js": { "bundled": 87646, diff --git a/.travis.yml b/.travis.yml index 19a848c7..f737e45c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ node_js: - "8" script: - make test # run tests - - make # ensure /src builds + - make build # ensure pkg builds + - make build_docs # ensure docz builds after_success: - make ci_publish diff --git a/Makefile b/Makefile index 3a4eba25..067b7056 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,34 @@ BUILD_DIR=dist .PHONY: all build_pre build_esm build_cjs build_styles clean publish test test_lint test_unit ci_publish help -all: clean build_esm build_cjs build_styles +help: + @echo "Makefile usage (: $(BUILD_DIR)):" + @echo "\nBUILD" + @echo " \`make build\`: build all" + @echo " \`make clean\`: delete " + @echo " \`make build_esm\`: package for ESM" + @echo " \`make build_cjs\`: package for CJS" + @echo " \`make build_styles\`: copy and compile sass" + @echo " \`make build_pre\`: create " + + @echo "\nTEST" + @echo " \`make test\`: test all (lint & unit)" + @echo " \`make lint\`: run tslint" + @echo " \`make test_unit\`: run jest unit tests" + + @echo "\nDOCS" + @echo " \`make docs_dev\`: run docz" + @echo " \`make docs_build\`: build docz" + @echo " \`make docs_publish\`: publish to GitHub Pages" + + @echo "\nETC" + @echo " \`make help\`: show this message" + @echo " \`make publish\`: publish to npm" + @echo " \`make ci_publish\`: publish coverage" + + +### Build +build: clean build_esm build_cjs build_styles @sed 's/"dist\//"/g' package.json > $(BUILD_DIR)/package.json build_pre: @@ -26,10 +53,12 @@ clean: @echo "Deleting $(BUILD_DIR)" @rm -rf $(BUILD_DIR) +### Publish publish: @echo "Publishing to NPM" @cd $(BUILD_DIR) && npm publish +### Test test: lint test_unit lint: @@ -40,26 +69,21 @@ test_unit: @echo "Running tests" @npx jest --coverage +### CI ci_publish: @echo "Publishing coverage" @cat ./.coverage/lcov.info | npx coveralls -help: - @echo "Makefile usage (: $(BUILD_DIR)):" - @echo "\nBUILD" - @echo " \`make\`: build all" - @echo " \`make clean\`: delete " - @echo " \`make build_esm\`: package for ESM" - @echo " \`make build_cjs\`: package for CJS" - @echo " \`make build_styles\`: copy and compile sass" - @echo " \`make build_pre\`: create " - @echo "\nTEST" - @echo " \`make test\`: test all (lint & unit)" - @echo " \`make lint\`: run tslint" - @echo " \`make test_unit\`: run jest unit tests" +### Docs +docs_dev: + @echo "Running docs dev" + @npx docz dev - @echo "\nETC" - @echo " \`make help\`: show this message" - @echo " \`make publish\`: publish to npm" - @echo " \`make ci_publish\`: publish coverage" +docs_build: + @echo "Running docs build" + @npx docz build + +docs_publish: + @echo "Publishing to GitHub pages" + @npx gh-pages -d .docz/dist -m \"Deploy Docs [skip ci]\" diff --git a/doczrc.js b/doczrc.js index 321f7717..928def21 100644 --- a/doczrc.js +++ b/doczrc.js @@ -3,7 +3,7 @@ const path = require("path"); export default { - base: "rbx", + base: "/rbx", // unfortnately, "too-many-modules" // https://github.com/codesandbox/codesandboxer/blob/af013874f5a2f7bb6325c9608597883a8f5061ef/packages/codesandboxer-fs/src/assembleFiles.js#L120 codeSandbox: false, @@ -11,8 +11,9 @@ export default { "The Comprehensive Bulma UI Framework for React. This is a lightweight, yet robust, React framework that enables rapid, beautiful web development.", files: "**/*(.docs)?*.mdx", htmlContext: { - favicon: "public/favicon.ico" + favicon: "/rbx/public/favicon.ico" }, + indexHtml: "src/__docs__/index.html", modifyBundlerConfig: config => { config.resolve.alias["src"] = path.join(__dirname, "./src"); @@ -26,7 +27,7 @@ export default { }, // we manually create them rather than relying on React-Docgen propsParser: false, - public: "docs/public", + public: "src/__docs__/public", themeConfig: { colors: { white: "#FFFFFF", diff --git a/package.json b/package.json index b5629fa8..cb2f58b5 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,13 @@ "type": "git", "url": "git+https://github.com/dfee/rbx.git" }, + "scripts": { + "build": "make build", + "docs:build": "make docs_build", + "docs": "make docs_dev", + "lint": "make lint", + "test": "make test" + }, "keywords": [ "react", "bulma", diff --git a/rbx.code-workspace b/rbx.code-workspace deleted file mode 100644 index fae55ce5..00000000 --- a/rbx.code-workspace +++ /dev/null @@ -1,13 +0,0 @@ -{ - "folders": [ - { - "path": "." - }, - { - "path": "docs" - } - ], - "settings": { - "typescript.tsdk": "node_modules/typescript/lib" - } -} diff --git a/src/__docs__/components/feature.tsx b/src/__docs__/components/feature.tsx index 4b0e9c5f..357d24ea 100644 --- a/src/__docs__/components/feature.tsx +++ b/src/__docs__/components/feature.tsx @@ -1,4 +1,6 @@ +import { Link } from "docz"; import React from "react"; + import { Variables } from "src/base/helpers/variables"; import { Control, Field, Tag } from "src/elements"; @@ -26,20 +28,20 @@ export const Feature = Object.assign( secondaryColor, url, }: FeatureProps) => { - const asType: keyof JSX.IntrinsicElements | undefined = - url === undefined ? undefined : "a"; const tagGroupProps = url === undefined ? {} + : /^\/[a-z]/.test(url) // Local path, e.g. '/somewhere' + ? { as: Link, to: url } : { + as: "a" as keyof JSX.IntrinsicElements, href: url, - // if path starts with '/[a-z]', assume local, else external - target: /^\/[a-z]/.test(url) ? undefined : "_blank", + target: "_blank", }; return ( - + {primaryName} {secondaryName} @@ -59,7 +61,7 @@ export const AsDoc: React.FC = ({ asType }) => ( primaryColor="light" secondaryName={asType} secondaryColor="warning" - url="/rbx/architecture/inversion-of-control" + url="/architecture/inversion-of-control" /> ); @@ -102,7 +104,7 @@ export const CustomizeFeature: React.FC = ({ primaryColor="light" secondaryName={name} secondaryColor={color} - url="/rbx/architecture/customize" + url="/architecture/customize" /> ); }; diff --git a/src/__docs__/etc.mdx b/src/__docs__/etc.mdx index 9b2a09d1..9fd48308 100644 --- a/src/__docs__/etc.mdx +++ b/src/__docs__/etc.mdx @@ -8,10 +8,10 @@ route: /architecture/etc ## Building & Commands -You'll notice the `package.json` scripts are virtually empty. +You'll notice the `package.json` scripts are very simple. That's because the build instructions were getting complex, so they were moved into a [`Makefile`](https://github.com/dfee/rbx/blob/master/Makefile). -By running the `make help` command in the root of a cloned repo, you'll see the available options (including building, testing, etc.) +By running the `make` command in the root of a cloned repo, you'll see the available options (including building, testing, etc.) ### Testing diff --git a/src/__docs__/index.html b/src/__docs__/index.html new file mode 100644 index 00000000..15035d81 --- /dev/null +++ b/src/__docs__/index.html @@ -0,0 +1,27 @@ + + + + + + + + + {{ title }} + {{ head }} + + + + + +
+ {{ footer }} + + + + diff --git a/src/__docs__/public/favicon-16x16.png b/src/__docs__/public/favicon-16x16.png new file mode 100644 index 00000000..28e361ac Binary files /dev/null and b/src/__docs__/public/favicon-16x16.png differ diff --git a/src/__docs__/public/favicon-32x32.png b/src/__docs__/public/favicon-32x32.png new file mode 100644 index 00000000..903f79b5 Binary files /dev/null and b/src/__docs__/public/favicon-32x32.png differ diff --git a/src/__docs__/public/favicon.ico b/src/__docs__/public/favicon.ico new file mode 100644 index 00000000..e8903cef Binary files /dev/null and b/src/__docs__/public/favicon.ico differ diff --git a/src/__docs__/public/srcdoc-polyfill.min.js b/src/__docs__/public/srcdoc-polyfill.min.js new file mode 100644 index 00000000..5421ec8e --- /dev/null +++ b/src/__docs__/public/srcdoc-polyfill.min.js @@ -0,0 +1,4 @@ +/*! srcdoc-polyfill - v1.0.0 - 2017-01-29 +* http://github.com/jugglinmike/srcdoc-polyfill/ +* Copyright (c) 2017 Mike Pennisi; Licensed MIT */ +!function(a,b){var c=window.srcDoc;"function"==typeof define&&define.amd?define(["exports"],function(d){b(d,c),a.srcDoc=d}):"object"==typeof exports?b(exports,c):(a.srcDoc={},b(a.srcDoc,c))}(this,function(a,b){var c,d,e,f=!!("srcdoc"in document.createElement("iframe")),g="Polyfill may not function in the presence of the `sandbox` attribute. Consider using the `force` option.",h=/\ballow-same-origin\b/,i=function(a,b){var c=a.getAttribute("sandbox");"string"!=typeof c||h.test(c)||(b&&b.force?a.removeAttribute("sandbox"):b&&b.force===!1||(e(g),a.setAttribute("data-srcdoc-polyfill",g)))},j={compliant:function(a,b,c){b&&(i(a,c),a.setAttribute("srcdoc",b))},legacy:function(a,b,c){var d;a&&a.getAttribute&&(b?a.setAttribute("srcdoc",b):b=a.getAttribute("srcdoc"),b&&(i(a,c),d="javascript: window.frameElement.getAttribute('srcdoc');",a.contentWindow&&(a.contentWindow.location=d),a.setAttribute("src",d)))}},k=a;if(e=window.console&&window.console.error?function(a){window.console.error("[srcdoc-polyfill] "+a)}:function(){},k.set=j.compliant,k.noConflict=function(){return window.srcDoc=b,k},!f)for(k.set=j.legacy,d=document.getElementsByTagName("iframe"),c=d.length;c--;)k.set(d[c])}); \ No newline at end of file diff --git a/tsconfig.build.json b/tsconfig.build.json index bca87a30..04437117 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,5 +5,5 @@ "outDir": "./dist" }, "include": ["src"], - "exclude": ["**/__tests__", "**/__mocks__"] + "exclude": ["**/__tests__", "**/__mocks__", "**/__docs__"] }