-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from NicolasOmar/feature/create-widgets-structure
Feature | Create a 'Widgets' framework structure | Front End
- Loading branch information
Showing
41 changed files
with
729 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react' | ||
import { array, bool, element, elementType, object, oneOf, oneOfType, string } from 'prop-types' | ||
// CONSTANTS | ||
import BULMA_STYLES from '../../../constants/bulma-styles.json' | ||
// FUNCTIONS | ||
import { parseObjKeys, parseFieldConfigToClasses } from '../../../functions/parsers' | ||
|
||
const { columnSizes } = BULMA_STYLES | ||
|
||
const Column = ({ | ||
_key = null, | ||
testId = null, | ||
width = null, | ||
isCentered = false, | ||
isContainer = false, | ||
isMultiline = false, | ||
children = null, | ||
styles = {} | ||
}) => { | ||
const columnClasses = parseFieldConfigToClasses({ | ||
useCommonClasses: true, | ||
fieldConfig: { isCentered, isMultiline }, | ||
fieldName: isContainer ? 'columns' : 'column', | ||
otherClasses: width ? [columnSizes[width]] : [] | ||
}) | ||
|
||
return ( | ||
<section key={_key} data-testid={testId} className={columnClasses} style={styles}> | ||
{children} | ||
</section> | ||
) | ||
} | ||
|
||
export default Column | ||
|
||
Column.propTypes = { | ||
_key: string.isRequired, | ||
testId: string.isRequired, | ||
width: oneOf(parseObjKeys(columnSizes, true)), | ||
isCentered: bool, | ||
isContainer: bool, | ||
isMultiline: bool, | ||
children: oneOfType([element, array, elementType]), | ||
styles: object | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import Column from '.' | ||
// APP_ROUTES | ||
import { STORYBOOK_ROUTES } from '../../../constants/routes.json' | ||
// CONSTANTS | ||
import { columnSizes } from '../../../constants/bulma-styles.json' | ||
// FUNCTIONS | ||
import { parseObjKeys } from '../../../functions/parsers' | ||
// MOCKS | ||
// import mocks from './index.mocks.json' | ||
|
||
export default { | ||
title: `${STORYBOOK_ROUTES.ATOMS}/Column`, | ||
component: Column, | ||
argTypes: { | ||
width: { | ||
options: parseObjKeys(columnSizes) | ||
} | ||
} | ||
// args: mocks.minimalConfig | ||
} | ||
|
||
const Template = args => <Column {...args} /> | ||
|
||
export const Minimal = Template.bind({}) | ||
Minimal.storyName = 'Minimal config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
// CONSTANTS | ||
import { bool, number, oneOf } from 'prop-types' | ||
import BULMA_STYLES from '../../../constants/bulma-styles.json' | ||
// FUNCTIONS | ||
import { parseFieldConfigToClasses, parseObjKeys } from '../../../functions/parsers' | ||
|
||
const { colors, sizes } = BULMA_STYLES | ||
|
||
const ProgressBar = ({ | ||
value = 0, | ||
maxValue = 100, | ||
isLoading = false, | ||
color = parseObjKeys(colors)[7], | ||
size = parseObjKeys(sizes)[1] | ||
}) => { | ||
const progressClasses = parseFieldConfigToClasses({ | ||
fieldName: 'progress', | ||
otherClasses: [colors[color], sizes[size]] | ||
}) | ||
|
||
return isLoading ? ( | ||
<progress | ||
data-testid="test-loading-progress-bar" | ||
className={progressClasses} | ||
max={maxValue} | ||
></progress> | ||
) : ( | ||
<progress | ||
data-testid="test-progress-bar" | ||
className={progressClasses} | ||
value={value} | ||
max={maxValue} | ||
> | ||
{`${value}%`} | ||
</progress> | ||
) | ||
} | ||
|
||
export default ProgressBar | ||
|
||
ProgressBar.propTypes = { | ||
// BASE PROPS | ||
value: number, | ||
maxValue: number, | ||
isLoading: bool, | ||
// STYLE PROPS | ||
color: oneOf(parseObjKeys(colors)), | ||
size: oneOf(parseObjKeys(sizes)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"isHalfSize": { | ||
"value": 50 | ||
}, | ||
"isSuccessColor": { | ||
"color": "success" | ||
}, | ||
"isLargeSize": { | ||
"size": "large" | ||
}, | ||
"isLoading": { | ||
"isLoading": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react' | ||
import ProgressBar from '.' | ||
// APP_ROUTES | ||
import { STORYBOOK_ROUTES } from '../../../constants/routes.json' | ||
// CONSTANTS | ||
import { colors, sizes } from '../../../constants/bulma-styles.json' | ||
// FUNCTIONS | ||
import { parseObjKeys } from '../../../functions/parsers' | ||
// MOCKS | ||
import mocks from './index.mocks.json' | ||
|
||
export default { | ||
title: `${STORYBOOK_ROUTES.ATOMS}/ProgressBar`, | ||
component: ProgressBar, | ||
argTypes: { | ||
color: { | ||
options: parseObjKeys(colors) | ||
}, | ||
size: { | ||
options: parseObjKeys(sizes) | ||
} | ||
} | ||
} | ||
|
||
const Template = args => <ProgressBar {...args} /> | ||
|
||
export const Minimal = Template.bind({}) | ||
Minimal.storyName = 'Minimal config' | ||
|
||
export const IsHalfSize = Template.bind({}) | ||
IsHalfSize.storyName = 'Is half size' | ||
IsHalfSize.args = mocks.isHalfSize | ||
|
||
export const IsSuccessColor = Template.bind({}) | ||
IsSuccessColor.storyName = 'Has other color' | ||
IsSuccessColor.args = { | ||
...IsHalfSize.args, | ||
...mocks.isSuccessColor | ||
} | ||
|
||
export const IsLargeSize = Template.bind({}) | ||
IsLargeSize.storyName = 'Has large size' | ||
IsLargeSize.args = { | ||
...IsSuccessColor.args, | ||
...mocks.isLargeSize | ||
} | ||
|
||
export const isLoading = Template.bind({}) | ||
isLoading.storyName = 'Is just loading' | ||
isLoading.args = { | ||
...IsLargeSize.args, | ||
...mocks.isLoading | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.