Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
v3.0.0 (#104)
Browse files Browse the repository at this point in the history
* All dependecies are up to date + jest.mocked instead of ts-jest mocked due to jestjs/jest#12089

* Example removed

* React Styleguidist first try

* Better documentation

* Styled documentation, changed min & max validators, removed special validators, workflows are tuned up

* Reusable docs workflow

* Reusable docs workflow fix

* Additional item in changelog

* Reusable docs workflow fix

* Validators refactored

* Invert validators result

* Readme

* min & length validators + integration test suites

* fix

* fix

* one more fix

* Exclude/ignore file(s) from Jest coverage by not running relevant tests

* fix

* code dublication avoided

* Seems work

* Bumped dependencies

* Docs
  • Loading branch information
boonya authored Jan 26, 2022
1 parent f7851f2 commit 703203f
Show file tree
Hide file tree
Showing 116 changed files with 29,225 additions and 37,579 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
dist
coverage
example
docs
styleguide
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: "npm"
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "weekly"
27 changes: 2 additions & 25 deletions .github/workflows/push.yml → .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and test
name: Coverage

on:
push:
Expand All @@ -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
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 16 additions & 5 deletions .github/workflows/release.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
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
- run: npm run build
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}

docs:
needs: [ publish ]
steps:
- uses: ./.github/workflows/docs.yml
with:
targetFolder: docs
34 changes: 34 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ node_modules/
.npm

dist/

styleguide/
*.code-workspace
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*
.*
!CHANGELOG
!dist/*/*
!src/**/*
**/*.test.ts
**/*.spec.ts
**/.*
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.12
16
30 changes: 30 additions & 0 deletions .styleguidist/components/Button.js
Original file line number Diff line number Diff line change
@@ -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
ref={ref}
type={type || 'button'}
className={className}
{...props}
/>
);
});

Button.displayName = 'Button';

export default Button;
90 changes: 90 additions & 0 deletions .styleguidist/components/Checks.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="form-check" key={itemId}>
<input
className={inputClassName}
type="checkbox"
value={value}
id={itemId}
name={name}
/>
<label
className="form-check-label"
htmlFor={itemId}
>
{itemLabel}
</label>
</div>
);
});

return (
<div className="mb-3">
<legend>
{label}
{required && <span aria-hidden="true"> *</span>}
</legend>
<fieldset
ref={ref}
id={id}
aria-invalid={invalid}
aria-describedby={id && description && `${id}-description`}
className={fieldsetClassName}
>
{children}
</fieldset>
{description && (
<p
id={id && `${id}-description`}
className={invalid ? 'invalid-feedback' : 'valid-feedback'}
>
{description}
</p>
)}
</div>
)
});

Checks.displayName = 'Checks';

export default Checks;
16 changes: 16 additions & 0 deletions .styleguidist/components/Form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, {forwardRef, useState, useCallback} from 'react';

const Form = forwardRef((props, ref) => {

return (
<form
ref={ref}
noValidate
{...props}
/>
);
});

Form.displayName = 'Form';

export default Form;
55 changes: 55 additions & 0 deletions .styleguidist/components/Input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, {forwardRef, useMemo} from 'react';

const Input = forwardRef(({
id,
label,
description,
required,
['aria-invalid']: invalid,
...props
}, ref) => {

const inputClassName = useMemo(() => {
const classes = ['form-control'];

if (invalid === true) {
classes.push('is-invalid');
}

if (invalid === false) {
classes.push('is-valid');
}

return classes.join(' ');
}, [invalid]);

return (
<div className="mb-3">
<label htmlFor={id} className="form-label">
{label}
{required && <span aria-hidden="true"> *</span>}
</label>
<input
ref={ref}
id={id}
className={inputClassName}
aria-describedby={id && description && `${id}-description`}
autoComplete="off"
aria-invalid={invalid}
{...props}
/>
{description && (
<p
id={id && `${id}-description`}
className={invalid ? 'invalid-feedback' : 'valid-feedback'}
>
{description}
</p>
)}
</div>
);
});

Input.displayName = 'Input';

export default Input;
Loading

0 comments on commit 703203f

Please sign in to comment.