-
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 branch 'feat/-focus-mode-(#110)' of https://github.com/Undeadlo…
…l1/flow-todo into feat/-focus-mode-(#110)
- Loading branch information
Showing
19 changed files
with
195 additions
and
122 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
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 @@ | ||
export * from './TasksList'; |
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
20 changes: 20 additions & 0 deletions
20
src/components/unsorted/Autocomplete/Autocomplete.stories.tsx
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,20 @@ | ||
import React from 'react'; | ||
import { sections } from '../../storybookContants'; | ||
import { Autocomplete, AutocompleteProps } from './Autocomplete'; | ||
|
||
export default { | ||
component: Autocomplete, | ||
title: `${sections.unsorted}Autocomplete`, | ||
}; | ||
|
||
const props: AutocompleteProps = { | ||
label: 'Movies', | ||
onChange: console.log, | ||
options: [ | ||
{ label: 'The Godfather', value: 1972 }, | ||
{ label: 'The Shawshank Redemption', value: 1994 }, | ||
], | ||
}; | ||
|
||
export const Demo = (args) => <Autocomplete {...args} />; | ||
Demo.args = props; |
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,99 @@ | ||
import React, { memo } from 'react'; | ||
import { makeStyles } from '@material-ui/styles'; | ||
import { Box, TextField, Theme } from '@material-ui/core'; | ||
import MuiAutocomplete, { | ||
createFilterOptions, | ||
} from '@material-ui/lab/Autocomplete'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ root: {} })); | ||
|
||
interface OptionType { | ||
value: any; | ||
label: string; | ||
inputValue?: string; | ||
} | ||
|
||
export interface AutocompleteProps { | ||
label: string; | ||
options: OptionType[]; | ||
onChange: (value: any) => void; | ||
} | ||
|
||
const filter = createFilterOptions<OptionType>(); | ||
|
||
const Autocomplete = memo(function Autocomplete( | ||
props: AutocompleteProps, | ||
) { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Box className={classes.root}> | ||
<MuiAutocomplete | ||
freeSolo | ||
clearOnBlur | ||
selectOnFocus | ||
handleHomeEndKeys | ||
options={props.options} | ||
renderOption={(i) => i.label} | ||
filterOptions={(options, params) => { | ||
console.log('params: ', params); | ||
const filtered = filter(options, params); | ||
|
||
// Suggest the creation of a new value | ||
if (params.inputValue !== '') { | ||
filtered.push({ | ||
// TODO this. | ||
value: {}, | ||
inputValue: params.inputValue, | ||
// TODO: i18n | ||
label: `Add "${params.inputValue}"`, | ||
}); | ||
} | ||
|
||
return filtered; | ||
}} | ||
getOptionLabel={(option) => { | ||
// Value selected with enter, right from the input | ||
if (typeof option === 'string') { | ||
return option; | ||
} | ||
// Add "xxx" option created dynamically | ||
if (option.inputValue) { | ||
return option.inputValue; | ||
} | ||
// Regular option | ||
return option.label; | ||
}} | ||
renderInput={(params) => ( | ||
<TextField | ||
{...params} | ||
fullWidth | ||
variant="outlined" | ||
label={props.label} | ||
/> | ||
)} | ||
onChange={(event, newValue, reason) => { | ||
if (reason !== 'select-option') { | ||
return; | ||
} | ||
|
||
if (typeof newValue === 'string') { | ||
props.onChange(newValue); | ||
} else { | ||
console.log('on change newValue: ', newValue); | ||
// TODO: rename this. | ||
if (newValue?.inputValue) { | ||
newValue.label = newValue.inputValue; | ||
} | ||
console.log('newValue.value: ', newValue?.value); | ||
props.onChange(newValue); | ||
} | ||
}} | ||
/> | ||
</Box> | ||
); | ||
}); | ||
|
||
Autocomplete.displayName = 'Autocomplete'; | ||
|
||
export { Autocomplete }; |
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 @@ | ||
export * from './Autocomplete'; |
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 |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import React from 'react'; | ||
import { sections } from '../storybookContants'; | ||
import { WhatDoYouFeelSlider } from './WhatDoYouFeelSlider'; | ||
import { | ||
WhatDoYouFeelSlider, | ||
WhatDoYouFeelSliderProps, | ||
} from './WhatDoYouFeelSlider'; | ||
|
||
export default { | ||
component: WhatDoYouFeelSlider, | ||
title: `${sections.ui}WhatDoYouFeelSlider`, | ||
}; | ||
|
||
const props = {}; | ||
const props: WhatDoYouFeelSliderProps = { | ||
onChange: console.log, | ||
}; | ||
|
||
export const Demo = (args) => <WhatDoYouFeelSlider {...args} />; | ||
Demo.args = props; |
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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import React from 'react'; | ||
import { sections } from '../../components/storybookContants'; | ||
import { FocusModePage } from './FocusModePage'; | ||
import { FocusModePage, FocusModePageProps } from './FocusModePage'; | ||
import { tasksMock } from '../../components/dataMocks'; | ||
|
||
export default { | ||
component: FocusModePage, | ||
title: sections.pages + 'FocusModePage', | ||
}; | ||
|
||
const props = {}; | ||
const props = { | ||
isLoading: false, | ||
tasks: tasksMock, | ||
} as FocusModePageProps; | ||
|
||
export const Demo = (args) => <FocusModePage {...args} />; | ||
Demo.args = props; |
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 |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import { Box } from '@material-ui/core'; | ||
import React, { memo } from 'react'; | ||
import { Box, Theme } from '@material-ui/core'; | ||
import { makeStyles } from '@material-ui/styles'; | ||
import { TasksList } from '../../components/tasks/TasksList'; | ||
import { WhatDoYouFeelSlider } from '../../components/unsorted/WhatDoYouFeelSlider'; | ||
import { Task } from '../../entities/Task'; | ||
import { If } from 'react-if'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ root: {} })); | ||
export interface FocusModePageProps { | ||
tasks: Task[]; | ||
isLoading: boolean; | ||
} | ||
|
||
interface Props { | ||
}; | ||
|
||
const FocusModePage = memo((props: Props) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Box className={classes.root}> | ||
Boilerplate is ready for you to work on. | ||
</Box> | ||
); | ||
const FocusModePage = memo(function FocusModePage({ | ||
tasks, | ||
isLoading, | ||
}: FocusModePageProps) { | ||
return ( | ||
<Box> | ||
<Box mb={2}> | ||
<TasksList tasks={tasks} loading={isLoading} /> | ||
</Box> | ||
<If condition={!isLoading}> | ||
<WhatDoYouFeelSlider onChange={console.log} /> | ||
</If> | ||
</Box> | ||
); | ||
}); | ||
|
||
FocusModePage.displayName = 'FocusModePage'; | ||
|
||
export { FocusModePage } | ||
export { FocusModePage }; |
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
Oops, something went wrong.