Skip to content

Commit

Permalink
Release/0.7 (#456)
Browse files Browse the repository at this point in the history
* feat: rebase branch

* feat: rebase completed
  • Loading branch information
daniele-zurico authored Mar 30, 2023
1 parent da59c75 commit 1579a81
Show file tree
Hide file tree
Showing 169 changed files with 6,989 additions and 3,854 deletions.
17 changes: 10 additions & 7 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module.exports = {
core: {
builder: 'webpack5',
},
stories: ['../stories/**/*.stories.@(mdx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-docs',
'@storybook/addon-controls',
'storybook-css-modules-preset',
'@storybook/addon-a11y'
],
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-docs',
'@storybook/addon-controls',
'storybook-css-modules-preset',
'@storybook/addon-a11y',
],
};
29 changes: 6 additions & 23 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
// https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
import '../stories/govUkStyle.css';
export const parameters = {
// https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args
actions: { argTypesRegex: '^on.*' },
options: {
storySort: (a, b) => {
let order = 2000;
if (a[0].includes('dcxlibrary-form')) {
return order;
} else if (a[0].includes('progress')) {
return order--;
} else if (a[0].includes('copy')) {
return order--;
} else if (a[0].includes('tabs')) {
return order--;
} else if (a[0].includes('table')) {
return order--;
} else if (a[0].includes('details')) {
return order--;
}
else {
return 0;
}
}
}
};
storySort: {
order: ['DCXLibrary', ['Introduction','Utils', 'Form', 'CopyToClipboard', 'Details', 'Tabs', 'Table', 'Changelog']]
},
},
};
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## 0.7.0 (27/03/2023)

<a name="0.7.0"></a>

- [Details - add prop for summaryText](https://github.com/Capgemini/dcx-react-library/issues/438)
- [FormSelect - add extra props](https://github.com/Capgemini/dcx-react-library/issues/441)
- [Checkbox - support anchor elements](https://github.com/Capgemini/dcx-react-library/issues/431)
- [Autocomplete - sorting results](https://github.com/Capgemini/dcx-react-library/issues/422)
- [Autocomplete - add id prop for hint and label](https://github.com/Capgemini/dcx-react-library/issues/439)
- [FormSelect - add extra default classes](https://github.com/Capgemini/dcx-react-library/issues/390)
- [FormInput - add the ability to position the error after the hint](https://github.com/Capgemini/dcx-react-library/issues/405)
- [All component - add tabindex property](https://github.com/Capgemini/dcx-react-library/issues/301)
- [allow the library to work with node18](https://github.com/Capgemini/dcx-react-library/issues/376)

**New components**

- [classNames utils](https://github.com/Capgemini/dcx-react-library/issues/412)
- [TextCharacterCount component](https://github.com/Capgemini/dcx-react-library/issues/414)

**Documentation**

- [Storybook - enhancement](https://github.com/Capgemini/dcx-react-library/issues/430)
- [Storybook - enhancement](https://github.com/Capgemini/dcx-react-library/issues/413)
- [Storybook - enhancement](https://github.com/Capgemini/dcx-react-library/issues/408)

**Dependencies**

- [lodash - removed](https://github.com/Capgemini/dcx-react-library/issues/420)
- [bumping versions](https://github.com/Capgemini/dcx-react-library/issues/403)

## 0.6.0 (10/01/2023)

<a name="0.6.0"></a>
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,27 @@ Thanks goes to these wonderful people
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/szilvihorvath">
<img src="https://avatars.githubusercontent.com/u/50360435?v=4" width="100px;" alt="szilvi-horvath"/>
<br />
<sub><b>Szilvi Horvath</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Jaya-Rathore">
<img src="https://avatars.githubusercontent.com/u/119496797?v=4" width="100px;" alt="jaya-rathore"/>
<br />
<sub><b>Jaya Rathore</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/arpakuma">
<img src="https://avatars.githubusercontent.com/u/128031818?v=4" width="100px;" alt="arpana-kumari"/>
<br />
<sub><b>Arpana Kumari</b></sub>
</a>
</td>
</tr>
</table>
18 changes: 9 additions & 9 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "6.2.0",
"@fortawesome/free-solid-svg-icons": "6.2.0",
"@fortawesome/fontawesome-svg-core": "6.3.0",
"@fortawesome/free-solid-svg-icons": "6.3.0",
"@fortawesome/react-fontawesome": "0.2.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.4.3",
"@types/jest": "29.2.0",
"@types/node": "18.11.8",
"@types/jest": "29.5.0",
"@types/node": "18.15.5",
"microbundle": "0.15.1",
"react-router-dom": "6.4.2",
"react-router-dom": "6.9.0",
"react-scripts": "5.0.1",
"typescript": "4.8.4"
"typescript": "5.0.2"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -42,7 +42,7 @@
},
"devDependencies": {
"@types/react-router-dom": "^5.3.3",
"node-sass": "7.0.1",
"web-vitals": "^2.1.4"
"node-sass": "8.0.0",
"web-vitals": "3.3.0"
}
}
45 changes: 45 additions & 0 deletions example/src/components/AutocompleteDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ const firstSearch = [
const secondSearch = ['Persimmon', 'Peach'];
const thirdSearch = ['Persimmon'];

const handleSearch = (value: string, options: string[]) => {
return options
.filter((optionsName) =>
optionsName.toLowerCase().includes(value.toLowerCase())
)
.sort((a, b) => {
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
});
};

export const AutocompleteDemo = () => {
const [selected, setSelected] = React.useState('');
const handleSelected = (value: string) => setSelected(value);
Expand Down Expand Up @@ -123,6 +139,35 @@ export const AutocompleteDemo = () => {
resultActiveClass="resultActiveClass"
notFoundText="No fruit found"
/>
<h2>With search and alphabet sort</h2>
<Autocomplete
options={[
'Zucchini',
'Tangelo',
'Kumquat',
'Jambul',
'Peach',
'Pomegranate',
'Pineapple',
'Coconut',
'Mulberry',
'Banana',
'Mango',
'Acerola',
'Lychee',
]}
defaultValue=""
minCharsBeforeSearch={1}
minCharsMessage="Type at least 1 character to see the available options"
debounceMs={100}
hintText="click inside the input to see the prompt"
hintClass="hintClass"
resultUlClass="resultUlClass"
resultlLiClass="resultlLiClass"
resultNoOptionClass="resultNoOptionClass"
resultActiveClass="resultActiveClass"
notFoundText="No fruit found"
/>
</>
);
};
66 changes: 66 additions & 0 deletions example/src/components/CharacterCountDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { useRef } from 'react';
import { Button, CharacterCount } from '@capgeminiuk/dcx-react-library';

export const CharacterCountDemo = () => {
const textRef = useRef<any>(null);
const [value, setValue] = React.useState<string>('');
const edit = () => {
setValue('prefill value');
};

return (
<>
<h1>Character Count Component</h1>
<form style={{ padding: '10px' }}>
<CharacterCount
label="Label for text area"
hint={{
text: 'Type more than 15 characters to see the message change',
}}
maxLength={15}
rows={5}
cols={50}
ref={textRef}
value={value}
onChange={(evt) => setValue(evt.currentTarget.value)}
/>
<Button onClick={() => textRef.current.reset()} label="Cancel" />
<Button onClick={edit} label="edit" />
</form>

<h2>Constrained</h2>
<CharacterCount
label="Label for text area"
hint={{
text: 'Type more than 15 characters to see the limitation',
}}
maxLength={15}
constrained={true}
rows={5}
cols={50}
/>
<h2>Threshold</h2>
<CharacterCount
label="Label for text area"
hint={{
text: 'Type more than 12 characters to see the message',
}}
maxLength={15}
threshold={80}
rows={5}
cols={50}
/>
<h2>Word Count</h2>
<CharacterCount
label="Label for text area"
hint={{
text: 'Type more than 15 words to see the message change',
}}
maxLength={15}
limitType="words"
rows={5}
cols={50}
/>
</>
);
};
37 changes: 37 additions & 0 deletions example/src/components/FormRadioDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,43 @@ export const FormRadioDemo = () => {
onChange={handleGroupConditionalChange}
/>
<br />

<h4>Radio with custom label</h4>
<RadioGroup
ariaDescribedBy="basic-radio-group-tag"
name="group3"
items={[
{
id: 'radio-1',
label: (
<>
This is a custom label <a href="#">hello</a>
</>
),
value: 'value-1',
selected: groupSelected === 'radio-1',
},
{
id: 'radio-2',
label: 'Option 2',
value: 'value-2',
selected: groupSelected === 'radio-2',
},
{
id: 'radio-3',
label: 'Option 3',
disabled: true,
hint: {
text: 'Hint text for this item',
position: 'above',
},
value: 'value-3',
selected: groupSelected === 'radio-3',
},
]}
//@ts-ignore
onChange={handleGroupConditionalChange}
/>
</>
);
};
1 change: 1 addition & 0 deletions example/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export { CopyToClipboardDemo } from './CopyToClipboardDemo';
export { TableDemo } from './TableDemo';
export { TooltipDemo } from './TooltipDemo';
export { DetailsDemo } from './DetailsDemo';
export { CharacterCountDemo } from './CharacterCountDemo';
export * from './library-candidates';
23 changes: 13 additions & 10 deletions example/src/components/library-candidates/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSpinner } from '@fortawesome/free-solid-svg-icons';
import { FormInput, Button } from '@capgeminiuk/dcx-react-library';
import { FormInput, Button, classNames } from '@capgeminiuk/dcx-react-library';
import { Label } from '../../generated-components';

const initialState = {
Expand Down Expand Up @@ -220,9 +220,10 @@ export const LoginForm = ({
return (
<form {...formProps}>
<div
className={['form-group', userNameErrorState ? 'has-error' : ''].join(
' '
)}
className={classNames([
'form-group',
{ 'has-error': userNameErrorState },
])}
>
<Label htmlFor="username" className="control-label">
{usernameLabel}
Expand All @@ -249,9 +250,10 @@ export const LoginForm = ({
</div>

<div
className={['form-group', passwordErrorState ? 'has-error' : ''].join(
' '
)}
className={classNames([
'form-group',
{ 'has-error': passwordErrorState },
])}
>
<Label htmlFor="password" className="control-label">
{passwordLabel}
Expand Down Expand Up @@ -289,9 +291,10 @@ export const LoginForm = ({
<FontAwesomeIcon icon={faSpinner} className="fa-spin" />
</div>
}
className={['btn btn-primary', isLoading ? 'btn-loading' : ''].join(
' '
)}
className={classNames([
'btn btn-primary',
{ 'btn-loading': isLoading },
])}
//@ts-ignore
type="submit"
/>
Expand Down
2 changes: 2 additions & 0 deletions example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
TooltipDemo,
RangeDemo,
DetailsDemo,
CharacterCountDemo,
} from './components';
import './global-styles.scss';
import { Login } from './pages/Login';
Expand Down Expand Up @@ -51,6 +52,7 @@ const App = () => (
<Route path="/table" element={<TableDemo />} />
<Route path="/tooltipDemo" element={<TooltipDemo />} />
<Route path="/details" element={<DetailsDemo />} />
<Route path="/characterCount" element={<CharacterCountDemo />} />
</Routes>
</BrowserRouter>
</div>
Expand Down
Loading

0 comments on commit 1579a81

Please sign in to comment.