diff --git a/.editorconfig b/.editorconfig index d7ea4c8..60411d1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,8 @@ trim_trailing_whitespace = true [*.md] indent_style = space insert_final_newline = false +indent_size = 4 -[package.json] +[{*.yaml,*.yml,package.json}] indent_style = space indent_size = 2 diff --git a/.eslintignore b/.eslintignore index f900da5..501e4c1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,4 @@ node_modules dist coverage -example -docs +styleguide diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 45758a1..feb90ba 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,4 +8,4 @@ updates: - package-ecosystem: "npm" directory: "/" # Location of package manifests schedule: - interval: "daily" + interval: "weekly" diff --git a/.github/workflows/push.yml b/.github/workflows/coverage.yml similarity index 51% rename from .github/workflows/push.yml rename to .github/workflows/coverage.yml index 6376112..4d47ddc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/coverage.yml @@ -1,4 +1,4 @@ -name: Lint and test +name: Coverage on: push: @@ -8,37 +8,14 @@ on: - '**.md' branches: - main - pull_request: jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 16 - - run: npm ci - - run: npm run lint - test: - name: Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@master - with: - node-version: 16 - - run: npm ci - - run: npm run test:ci coverage: - needs: [ test ] - if: github.ref == 'refs/heads/main' name: Sending test coverage to Code Climate runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: 16 - run: npm ci diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..5385327 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,26 @@ +name: Publish documentation + +on: + workflow_call: + inputs: + targetFolder: + required: true + type: string + +jobs: + docs: + name: Build & publish documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm ci + - run: npm run build:docs + - uses: JamesIves/github-pages-deploy-action@4.1.5 + with: + branch: docs + folder: styleguide + target-folder: ${{ inputs.targetFolder }} + git-config-name: github-pages-deploy-action diff --git a/.github/workflows/release.yml b/.github/workflows/publish.yml similarity index 70% rename from .github/workflows/release.yml rename to .github/workflows/publish.yml index 4b78d94..40a9a91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/publish.yml @@ -1,35 +1,39 @@ -name: Lint, test, build and publish +name: Publish + on: release: types: [ published ] + jobs: lint: name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: 16 - run: npm ci - run: npm run lint + test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: 16 - run: npm ci - run: npm run test:ci + publish: needs: [ lint, test ] - name: Build & publish + name: Build & publish package runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: 16 - run: npm ci @@ -37,3 +41,10 @@ jobs: - uses: JS-DevTools/npm-publish@v1 with: token: ${{ secrets.NPM_TOKEN }} + + docs: + needs: [ publish ] + steps: + - uses: ./.github/workflows/docs.yml + with: + targetFolder: docs diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..20d8728 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,34 @@ +name: Verify + +on: + push: + tags-ignore: + - '*' + paths-ignore: + - '**.md' + branches: + - main + pull_request: + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm ci + - run: npm run lint + + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm ci + - run: npm run test:ci diff --git a/.gitignore b/.gitignore index 9b574d2..353f2e4 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,5 @@ node_modules/ .npm dist/ - +styleguide/ *.code-workspace diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..897fdd7 --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +* +.* +!CHANGELOG +!dist/*/* +!src/**/* +**/*.test.ts +**/*.spec.ts +**/.* diff --git a/.nvmrc b/.nvmrc index 2e0d662..b6a7d89 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16.12 +16 diff --git a/.styleguidist/components/Button.js b/.styleguidist/components/Button.js new file mode 100644 index 0000000..3c17bb2 --- /dev/null +++ b/.styleguidist/components/Button.js @@ -0,0 +1,30 @@ +import React, {forwardRef, useMemo} from 'react'; + +const Button = forwardRef(({type, ...props}, ref) => { + const className = useMemo(() => { + const classes = ['btn me-3']; + + if (type === 'reset') { + classes.push('btn-secondary') + } + else { + classes.push('btn-primary') + } + + return classes.join(' '); + }, [type]); + + + return ( + + ); +}); + +Button.displayName = 'Button'; + +export default Button; diff --git a/.styleguidist/components/Checks.js b/.styleguidist/components/Checks.js new file mode 100644 index 0000000..094698e --- /dev/null +++ b/.styleguidist/components/Checks.js @@ -0,0 +1,90 @@ +import React, {forwardRef, useMemo} from 'react'; + +const Checks = forwardRef(({ + items, + description, + label, + required, + id, + name, + ['aria-invalid']: invalid, +}, ref) => { + const inputClassName = useMemo(() => { + const classes = ['form-check-input']; + + if (invalid === true) { + classes.push('is-invalid'); + } + + if (invalid === false) { + classes.push('is-valid'); + } + + return classes.join(' '); + }, [invalid]); + + const fieldsetClassName = useMemo(() => { + const classes = []; + + if (invalid === true) { + classes.push('is-invalid'); + } + + if (invalid === false) { + classes.push('is-valid'); + } + + return classes.join(' '); + }, [invalid]); + + const children = items.map(([itemLabel, value]) => { + const itemId = `${id}-${itemLabel.toLowerCase().replace(/\s:#/ui, '-')}`; + return ( +
+ {description} +
+ )} ++ {description} +
+ )} +