Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.6.6 -> v0.7.0 #146

Merged
merged 75 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f87c6bb
Feat #43 - Tag, Link components
sam-dassana Aug 14, 2020
97d5e4f
Fix #47 - Fix Link props - both onClick & href are undef (#48)
sam-dassana Aug 14, 2020
ba77ee2
Chore #49- Upgrade Storybook and dependencies (#50)
sam-dassana Aug 18, 2020
caa3e01
feat #38 - Add eslint and fix lint errors & warnings (#39)
sam-dassana Aug 11, 2020
cb4b319
Feat #43 - Tag, Link components
sam-dassana Aug 14, 2020
0a9a022
Fix #47 - Fix Link props - both onClick & href are undef (#48)
sam-dassana Aug 14, 2020
2584b28
Chore #49- Upgrade Storybook and dependencies (#50)
sam-dassana Aug 18, 2020
427e22f
feat #3 - Input field component (#53)
nancy-dassana Aug 21, 2020
e0c0bc6
Feat #30 - Toggle and Icon components (#52)
sam-dassana Aug 21, 2020
9a88334
chore #41 - Add verify labels GitHub action (#42)
parth-dassana Aug 12, 2020
5b98c5b
Feat #43 - Tag, Link components
sam-dassana Aug 14, 2020
74d7d33
Fix #47 - Fix Link props - both onClick & href are undef (#48)
sam-dassana Aug 14, 2020
b41ca47
Chore #49- Upgrade Storybook and dependencies (#50)
sam-dassana Aug 18, 2020
2dba6fe
feat #38 - Add eslint and fix lint errors & warnings (#39)
sam-dassana Aug 11, 2020
c17778d
chore #41 - Add verify labels GitHub action (#42)
parth-dassana Aug 12, 2020
cc37822
Feat #43 - Tag, Link components
sam-dassana Aug 14, 2020
df26689
Fix #47 - Fix Link props - both onClick & href are undef (#48)
sam-dassana Aug 14, 2020
8ed4189
Chore #49- Upgrade Storybook and dependencies (#50)
sam-dassana Aug 18, 2020
e64138e
feat #3 - Input field component (#53)
nancy-dassana Aug 21, 2020
fc5b3fa
Feat #30 - Toggle and Icon components (#52)
sam-dassana Aug 21, 2020
81a4894
Bump up version to 0.2.0
parth-dassana Aug 21, 2020
0eb414d
Comment out icon component
parth-dassana Aug 21, 2020
64e7c7a
Update package.json
parth-dassana Aug 21, 2020
3f0ac79
Update index.ts
parth-dassana Aug 21, 2020
94568de
Merge branch 'master' into dev
parth-dassana Aug 21, 2020
062ccb0
Bump up package.json
parth-dassana Aug 21, 2020
e12ea02
Update package-lock.json
parth-dassana Aug 21, 2020
0fa95d0
fix #58 - Address icon, styles, global css, and typescript issues (#59)
parth-dassana Aug 21, 2020
62204c3
Merge branch 'master' into dev
parth-dassana Aug 24, 2020
e39215c
Merge branch 'master' into dev
parth-dassana Aug 24, 2020
d6aca00
chore #63 - Update .eslintrc.js (#64)
sam-dassana Aug 25, 2020
7cce5bd
feat #61 - Skeleton loader component (#66)
nancy-dassana Aug 25, 2020
f7b7331
feat #65 - Form Component (#67)
nancy-dassana Aug 27, 2020
8082187
Merge branch 'master' into dev
parth-dassana Aug 27, 2020
c562ceb
v0.2.4 -> v0.2.5
parth-dassana Aug 27, 2020
31e099f
feat #71 - Notification component (#72)
nancy-dassana Sep 2, 2020
2e5d713
Merge branch 'master' into dev
Sep 2, 2020
06d095a
feat #76 - Refactor Form.Button to be Form.SubmitButton (#77)
nancy-dassana Sep 8, 2020
70bf0c4
Merge branch 'master' into dev
Sep 8, 2020
8bfb295
feat #62 - Table component (#70)
sam-dassana Sep 10, 2020
f6a1d6f
Merge branch 'master' into dev
Sep 10, 2020
459e57f
feat #79 - Select component (#82)
nancy-dassana Sep 16, 2020
f74f43b
feat #83 - Add data-test attribute to components (#85)
nancy-dassana Sep 17, 2020
fa5706e
Merge branch 'master' into dev
Sep 17, 2020
5f641a6
Update failing snapshots
Sep 17, 2020
cc56fab
feat #88 - Fix type exports for rollup (#89)
nancy-dassana Sep 17, 2020
a50bd53
Merge branch 'master' into dev
Sep 17, 2020
f2bdaa4
feat #84 - Radio group component (#91)
nancy-dassana Sep 20, 2020
06873bc
feat #81 - Tree component (#86)
sam-dassana Sep 23, 2020
6f85686
feat #93 - Tooltip component (#95)
nancy-dassana Sep 28, 2020
caf6a10
feat #94 - Popover component (#96)
nancy-dassana Sep 29, 2020
cd22a92
Merge branch 'master' into dev
Sep 29, 2020
7466916
Feat #99, #101, #100 - Add new avatar component and enhancements for …
nancy-dassana Oct 8, 2020
cca500d
Merge branch 'master' into dev
Oct 8, 2020
0f81ad2
feat #92 - Theming (#97)
sam-dassana Oct 9, 2020
fd256f0
chore #106 - refac all component exports from default to named, add s…
sam-dassana Oct 12, 2020
40c8370
fix #108 - Fix colors, refac stylguide export (#109)
sam-dassana Oct 12, 2020
0351f2d
Merge branch 'master' into dev
Oct 12, 2020
cbccafa
Components theming (#121)
nancy-dassana Oct 20, 2020
662fb10
Merge branch 'master' into dev
Oct 20, 2020
3c3a88f
fix #123 - Fix line height in styleguide (#124)
sam-dassana Oct 20, 2020
2d7cb76
Merge branch 'master' into dev
Oct 20, 2020
2c667b4
chore #127, fix #126: Refac & bug-fix Icon component, bug-fix fieldLa…
sam-dassana Oct 22, 2020
7399654
Merge branch 'master' into dev
Oct 22, 2020
dc1adeb
feat - Add Table row click handler (#131)
sam-dassana Oct 29, 2020
37ffa54
Merge branch 'master' into dev
Oct 29, 2020
825e343
Form enhancements (#134)
nancy-dassana Nov 3, 2020
b56a2d3
Merge branch 'master' into dev
Nov 3, 2020
0280f62
fix #136 - Fix package publish github action (#137)
nancy-dassana Nov 3, 2020
85d3293
Merge branch 'master' into dev
Nov 3, 2020
aac8ecb
feat #139 - Add focused prop to FormInput and allow refs to be passed…
nancy-dassana Nov 9, 2020
5205de3
Merge branch 'master' into dev
Nov 9, 2020
e1ba07f
feat #144 - Form Toggle (#145)
nancy-dassana Nov 19, 2020
ba16308
Merge branch 'master' into dev
Nov 19, 2020
fc078b6
feat #142 - Table refactor (#143)
sam-dassana Nov 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module.exports = {
collectCoverageFrom: ['lib/**/*.{ts,tsx,js,jsx}'],
coverageDirectory: 'coverage',
preset: 'ts-jest',
resetMocks: true,
testEnvironment: 'node'
}
2,435 changes: 1,776 additions & 659 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dassana-io/web-components",
"version": "0.6.6",
"version": "0.7.0",
"publishConfig": {
"registry": "https://npm.pkg.github.com/dassana-io"
},
Expand All @@ -11,8 +11,8 @@
},
"dependencies": {
"@ant-design/icons": "^4.2.2",
"@dassana-io/web-utils": "^0.6.0",
"@storybook/addon-cssresources": "^6.0.27",
"@dassana-io/web-utils": "^0.7.2",
"@storybook/addon-cssresources": "^6.0.28",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/react-hooks": "^3.4.2",
Expand Down Expand Up @@ -77,14 +77,14 @@
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-image": "^2.0.5",
"@rollup/plugin-node-resolve": "^9.0.0",
"@storybook/addon-actions": "^6.0.27",
"@storybook/addon-essentials": "^6.0.27",
"@storybook/addon-links": "^6.0.27",
"@storybook/addon-storyshots": "^6.0.27",
"@storybook/addons": "^6.0.27",
"@storybook/preset-create-react-app": "^3.1.4",
"@storybook/react": "^6.0.27",
"@storybook/theming": "^6.0.27",
"@storybook/addon-actions": "^6.0.28",
"@storybook/addon-essentials": "^6.0.28",
"@storybook/addon-links": "^6.0.28",
"@storybook/addon-storyshots": "^6.0.28",
"@storybook/addons": "^6.0.28",
"@storybook/preset-create-react-app": "^3.1.5",
"@storybook/react": "^6.0.28",
"@storybook/theming": "^6.0.28",
"@svgr/rollup": "^5.4.0",
"@types/bytes": "^3.1.0",
"@types/classnames": "^2.2.10",
Expand Down
20 changes: 11 additions & 9 deletions src/__mocks__/table_mock_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import {
const { component, number, string } = ColumnTypes
const { none, byte, date, icon, link, toggle, tag } = ColumnFormats

export interface DataType {
string: string
number: number
date: number
export interface Data {
byte: number
tag: string
date: number
icon: string
icon_key: string
id: number
link: string
number: number
string: string
tag: string
toggle: boolean
icon_key: string
icon: string
}

export const dateFormat = 'MM/DD/YYYY'
Expand Down Expand Up @@ -94,12 +95,13 @@ const columns: ColumnType[] = [
}
]

const data: DataType[] = [
const data: Data[] = [
{
byte: 1024,
date: 1599193037581,
icon: 'test',
icon_key: 'dassana',
id: 0,
link: 'test',
number: 0,
string: 'Dassana',
Expand All @@ -108,6 +110,6 @@ const data: DataType[] = [
}
]

const tableProps: TableProps<DataType> = { columns, data }
const tableProps: TableProps<Data> = { columns, data }

export default tableProps
6 changes: 3 additions & 3 deletions src/components/Button/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { styleguide, themedStyles, ThemeType } from 'components/assets/styles'

const {
borderRadius,
colors: { blacks }
colors: { blacks, grays }
} = styleguide

const { dark, light } = ThemeType
Expand All @@ -19,10 +19,10 @@ const buttonPalette = {
},
[light]: {
color: blacks['lighten-30'],
disabledBgColor: blacks['lighten-90'],
disabledBgColor: grays.base,
hoverColor: blacks['darken-20'],
primaryBackgroundColor: blacks.base,
primaryDisabledBgColor: blacks['lighten-90'],
primaryDisabledBgColor: grays.base,
primaryDisabledTextColor: blacks['lighten-80'],
primaryHoverBgColor: blacks['lighten-50']
}
Expand Down
11 changes: 8 additions & 3 deletions src/components/Form/FieldLabel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cn from 'classnames'
import { createUseStyles } from 'react-jss'
import { Skeleton } from 'components/Skeleton'
import {
Expand Down Expand Up @@ -47,6 +48,7 @@ const useStyles = createUseStyles({
})

export interface FieldLabelProps {
classes?: string[]
fullWidth?: boolean
label: string
loading?: boolean
Expand All @@ -55,23 +57,26 @@ export interface FieldLabelProps {
}

const FieldLabel: FC<FieldLabelProps> = ({
classes = [],
fullWidth = false,
label,
loading = false,
required = false,
skeletonWidth = 100
}: FieldLabelProps) => {
const classes = useStyles({ fullWidth })
const fieldLabelClasses = useStyles({ fullWidth })

return (
<div className={classes.container}>
<div className={cn({ [fieldLabelClasses.container]: true }, classes)}>
{loading ? (
<Skeleton width={skeletonWidth} />
) : (
<>
<span>{label}</span>
{!required && (
<span className={classes.optional}>Optional</span>
<span className={fieldLabelClasses.optional}>
Optional
</span>
)}
</>
)}
Expand Down
5 changes: 5 additions & 0 deletions src/components/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const Template: Story<FormProps<UserModel>> = (args: FormProps<UserModel>) => (
name='severity'
options={basicOptions}
/>
<Form.Toggle
defaultChecked
label='Production Environment'
name='isProduction'
/>
<Form.Tree
label='Cloud Accounts'
name='defaultCheckedKeys'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/FormRadioGroup/FormRadioGroup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import FormRadioGroup, { FormRadioGroupProps } from './index'
import { mount, ReactWrapper } from 'enzyme'

jest.mock('react-hook-form', () => ({
...jest.requireActual('react-hook-form'),
...(jest.requireActual('react-hook-form') as {}),
Controller: () => <div />,
useFormContext: () => ({
control: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/FormSelect/FormSelect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import FormSelect, { FormSelectProps } from './index'
import { mount, ReactWrapper } from 'enzyme'

jest.mock('react-hook-form', () => ({
...jest.requireActual('react-hook-form'),
...(jest.requireActual('react-hook-form') as {}),
Controller: () => <div />,
useFormContext: () => ({
control: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const getMockFormContext = (isDirty = true) =>
formState: {
isDirty
},
getValues: jest.fn() as any,
handleSubmit: (onSubmit: any) => onSubmit()
} as reactHookForm.UseFormMethods)

Expand Down
9 changes: 6 additions & 3 deletions src/components/Form/FormSubmitButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ import React, { FC, useContext } from 'react'

export interface FormButtonProps
extends Omit<ButtonProps, 'loading' | 'onClick'> {
isDisabled?: (formState: FormStateProxy) => boolean
isDisabled?: (
formState: FormStateProxy,
formValues: Record<string, any>
) => boolean
}

const FormSubmitButton: FC<FormButtonProps> = ({
isDisabled,
...rest
}: FormButtonProps) => {
const { handleSubmit, formState } = useFormContext()
const { handleSubmit, formState, getValues } = useFormContext()
const { loading, onSubmit } = useContext(FieldContext)
const { isDirty } = formState

const isButtonDisabled = () =>
isDisabled ? isDisabled(formState) : !isDirty
isDisabled ? isDisabled(formState, getValues()) : !isDirty

useShortcut({
additionalConditionalFn: () => !isButtonDisabled(),
Expand Down
107 changes: 107 additions & 0 deletions src/components/Form/FormToggle/FormToggle.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { Controller } from 'react-hook-form'
import FieldContext from '../FieldContext'
import FieldLabel from '../FieldLabel'
import React from 'react'
import { Toggle } from 'components/Toggle'
import FormToggle, { FormToggleProps } from './index'
import { mount, ReactWrapper } from 'enzyme'

jest.mock('react-hook-form', () => ({
...(jest.requireActual('react-hook-form') as {}),
Controller: () => <div />,
useFormContext: () => ({
control: jest.fn(),
errors: () => ({ foo: true })
})
}))

let wrapper: ReactWrapper<FormToggleProps>

const mockOnSubmit = jest.fn()

beforeEach(() => {
wrapper = mount(
<FieldContext.Provider
value={{
initialValues: { foo: true },
loading: true,
onSubmit: mockOnSubmit
}}
>
<FormToggle label='foo' name='foo' />
</FieldContext.Provider>
)
})

afterEach(() => {
jest.resetAllMocks()
})

describe('FormToggle', () => {
it('renders', () => {
expect(wrapper).toHaveLength(1)
})

it('correctly passes a default value from initial values if it exists', () => {
expect(wrapper.find(Controller).props().defaultValue).toEqual(true)
})

it('correctly passes a default value from initial values if defaultChecked is true', () => {
wrapper = mount(
<FieldContext.Provider
value={{
initialValues: {},
loading: true,
onSubmit: mockOnSubmit
}}
>
<FormToggle defaultChecked label='foo' name='foo' />
</FieldContext.Provider>
)

expect(wrapper.find(Controller).props().defaultValue).toEqual(true)
})

it('should render a Toggle component', () => {
const mockOnChange = jest.fn()
const test = {
onChange: mockOnChange,
value: true
} as jest.Mocked<any>

const toggle = wrapper.find(Controller).invoke('render')!(test)

expect(toggle.type).toBe(Toggle)

toggle.props.onChange(true)

expect(mockOnChange).toHaveBeenCalled()
})

it('should not render the label with the default width if fullWidth is passed as true', () => {
const div = document.createElement('div')
div.setAttribute('id', 'container')
document.body.appendChild(div)

wrapper = mount(
<FieldContext.Provider
value={{
initialValues: {},
loading: true,
onSubmit: mockOnSubmit
}}
>
<FormToggle defaultChecked fullWidth label='foo' name='foo' />
</FieldContext.Provider>,
{
attachTo: document.getElementById('container')
}
)

const style = window.getComputedStyle(
wrapper.find(FieldLabel).getDOMNode()
)

expect(style.width).not.toEqual(255)
})
})
Loading