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

feat: add focus mode #129

Merged
merged 62 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
7c87212
feat: :construction: add lablel to tasks list
Undeadlol1 Nov 1, 2020
8876567
fix: "isStale" function
Undeadlol1 Nov 4, 2020
9b13804
fix: "isStale" function
Undeadlol1 Nov 4, 2020
3609ea4
Merge branch 'master' into feat/add-stale-condition-to-tasks-list
Undeadlol1 Nov 6, 2020
b73fcc9
feat: separate TasksList and TasksListItem
Undeadlol1 Nov 6, 2020
0eb71ca
fix: TaskListItem stories
Undeadlol1 Nov 6, 2020
4ced5aa
feat: add stale indicator to TasksListItem
Undeadlol1 Nov 6, 2020
aef3257
fix: unused import
Undeadlol1 Nov 6, 2020
eff89d6
fix: :bug: "isStale" not detecting stale tasks
Undeadlol1 Nov 6, 2020
18031ce
fix: remove console.logs
Undeadlol1 Nov 6, 2020
9f147cf
fix: remove loggings
Undeadlol1 Nov 6, 2020
3c197f7
ci: :arrow_down: downgrade eslint to pass CI tests
Undeadlol1 Nov 6, 2020
d016204
Merge remote-tracking branch 'origin/master' into feat/add-stale-cond…
Undeadlol1 Nov 6, 2020
9d63a4c
refactor: minor
Undeadlol1 Nov 6, 2020
656b1e8
feat: improve stale function
Undeadlol1 Nov 7, 2020
d5426f9
Merge remote-tracking branch 'origin/master' into feat/add-stale-cond…
Undeadlol1 Nov 7, 2020
ff69fe6
fix: forgot package-lock
Undeadlol1 Nov 7, 2020
5ca771a
feat: add test boilerplate for TaskService
Undeadlol1 Nov 7, 2020
0e98cb4
feat: :white_check_mark: add few "isStale" tests
Undeadlol1 Nov 7, 2020
b87f189
feat: :white_check_mark: add more tests
Undeadlol1 Nov 7, 2020
928ee62
refactor: minor
Undeadlol1 Nov 7, 2020
a7aecc4
ci: :green_heart: temporary disable caching to fix ci builds
Undeadlol1 Nov 7, 2020
19d8f7a
ci: :green_heart: reenable caching and add "package.json" to cach hash
Undeadlol1 Nov 7, 2020
36af82f
feat: rework hard choices
Undeadlol1 Nov 8, 2020
30a699b
refactor: minor
Undeadlol1 Nov 8, 2020
669ca96
Merge branch 'master' into feat/add-stale-condition-to-tasks-list
Undeadlol1 Nov 9, 2020
4de1902
ci: rename test workflow
Undeadlol1 Nov 9, 2020
61dda9d
ci: :green_heart: also cache node_modules
Undeadlol1 Nov 9, 2020
ebd4c7d
Merge remote-tracking branch 'origin/master' into feat/add-stale-cond…
Undeadlol1 Nov 9, 2020
b48cfbc
ci: fix typescript being downloaded unnecessary
Undeadlol1 Nov 9, 2020
3b30bd6
feat: add FocusModePage boilerplate
Undeadlol1 Nov 9, 2020
964d7b6
feat: add focue mode page rout
Undeadlol1 Nov 9, 2020
d10e9fa
Merge remote-tracking branch 'origin/master' into feat/-focus-mode-(#…
Undeadlol1 Nov 9, 2020
1efdb84
refactor: move files in proper folders
Undeadlol1 Nov 10, 2020
a0696e6
refactor: move files to appropriate folders
Undeadlol1 Nov 10, 2020
0b20ee6
feat: :construction: adding slider
Undeadlol1 Nov 10, 2020
1db77ae
feat: :construction: adding slider
Undeadlol1 Nov 10, 2020
9ad95ca
feat: add Icon component
Undeadlol1 Nov 10, 2020
778fb4f
feat: add "size" to Icon
Undeadlol1 Nov 10, 2020
4e6b3f5
feat: :construction: improving slider
Undeadlol1 Nov 10, 2020
d1e4f82
feat: add "onChange" to WhatDoYouFeelSlider
Undeadlol1 Nov 12, 2020
f6fa3ea
feat: :construction:
Undeadlol1 Nov 12, 2020
9520e81
feat: improve templates
Undeadlol1 Nov 12, 2020
67c6afb
refactor: :recycle: remove unnecessary container from TasksList
Undeadlol1 Nov 12, 2020
bfe1d78
Merge branch 'feat/add-stale-condition-to-tasks-list' into feat/-focu…
Undeadlol1 Nov 12, 2020
01c6469
feat: add Autocomplete
Undeadlol1 Nov 12, 2020
ad67924
feat: :construction: improving autocomplete
Undeadlol1 Nov 12, 2020
c0e9c3e
feat: :construction: improve autocomplete
Undeadlol1 Nov 12, 2020
1d6e3ee
Merge remote-tracking branch 'origin/master' into feat/-focus-mode-(#…
Undeadlol1 Nov 16, 2020
adf0e3f
feat: add TasksList to FocusModePage
Undeadlol1 Nov 16, 2020
d796819
fix: hide elements in FocusMode during loading
Undeadlol1 Nov 16, 2020
b85cd61
fix: type issues
Undeadlol1 Nov 16, 2020
13cea58
fix(storybook): delete unused story
Undeadlol1 Nov 16, 2020
534c6ab
Merge remote-tracking branch 'origin/master' into feat/-focus-mode-(#…
Undeadlol1 Nov 16, 2020
d610843
fix: remove unused imports
Undeadlol1 Nov 16, 2020
1a5e7e2
Merge branch 'feat/-focus-mode-(#110)' of https://github.com/Undeadlo…
Undeadlol1 Nov 16, 2020
8b8900f
refactor(TaskPage): :recycle:
Undeadlol1 Nov 16, 2020
dc31a53
refactor: :recycle: various
Undeadlol1 Nov 16, 2020
5eaaafb
feat: add options to autocomplete
Undeadlol1 Nov 16, 2020
f6c88ad
feat: add EmotionIconButton
Undeadlol1 Nov 16, 2020
bd74a15
feat: add "onClick" to EmotionIconButton
Undeadlol1 Nov 16, 2020
c3fc15b
feat: rework icons via EmotionIconButton
Undeadlol1 Nov 16, 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
10 changes: 8 additions & 2 deletions plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ module.exports = function (plop) {
{
type: 'add',
templateFile: 'templates/DumbComponent.txt',
path: './src/components/unsorted/{{pascalCase name}}.tsx',
path: './src/components/unsorted/{{pascalCase name}}/{{pascalCase name}}.tsx',
},
// Create storybook file.
{
type: 'add',
templateFile: 'templates/DumbComponent.stories.txt',
path: './src/components/unsorted/{{pascalCase name}}.stories.tsx',
path: './src/components/unsorted/{{pascalCase name}}/{{pascalCase name}}.stories.tsx',
},
// Create index file.
{
type: 'add',
templateFile: 'templates/DumbComponent.index.txt',
path: './src/components/unsorted/{{pascalCase name}}/index.ts',
},
],
});
Expand Down
11 changes: 10 additions & 1 deletion src/RouterAndDataLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { BrowserRouter, Route, Switch } from 'react-router-dom';
import useInterval from 'react-use/esm/useInterval';
import RewardModal from './components/rewards/RewardModal';
import DevelopmentOnlyMenu from './components/ui/DevelopmentOnlyMenu';
import { GlobalSnackbar } from './components/ui/GlobalSnackbar';
import NavBar from './components/ui/NavBar/NavBar';
import Sidebar from './components/ui/Sidebar';
import { GlobalSnackbar } from './components/unsorted/GlobalSnackbar';
import { ExpirienceProgressBar } from './components/users/ExpirienceProgressBar';
import FAQPage from './pages/FAQPage';
import { FocusModePage } from './pages/FocusModePage';
import HomePage from './pages/IndexPage/IndexPage';
import PrivacyPage from './pages/PrivacyPage';
import { ProfilePageContainer } from './pages/ProfilePage/ProfilePage';
Expand Down Expand Up @@ -134,6 +135,14 @@ export default memo((props: { children?: JSX.Element }) => {
<Route path="/tasks/:taskId">
<TaskPage />
</Route>
<Route path="/focus">
{/* TODO use a container instead of dumb component. */}
<FocusModePage
tasksToList={[]}
isLoading={false}
tasksForAutoComplete={[]}
/>
</Route>
<Route path="/tasks">
<TasksPage />
</Route>
Expand Down
4 changes: 2 additions & 2 deletions src/components/tasks/DayliTasksStreak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import debug from 'debug';
import React, { memo } from 'react';
import { useTypedTranslate } from '../../services';
import DailyStreak from '../../services/dailyStreak';
import { IDayliStreak } from "../../entities/IDayliStreak";
import { NumbersAnimatedOnUpdate } from '../unsorted/NumbersAnimatedOnUpdate';
import { IDayliStreak } from '../../entities/IDayliStreak';
import { NumbersAnimatedOnUpdate } from '../ui/NumbersAnimatedOnUpdate';

const componentName = 'DayliTasksStreak';
const log = debug(componentName);
Expand Down
4 changes: 2 additions & 2 deletions src/components/tasks/TasksDoneToday.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { Theme, Zoom } from '@material-ui/core';
import classNames from 'classnames';
import { useTypedTranslate } from '../../services/index';
import DayliTasksStreak from './DayliTasksStreak';
import { IDayliStreak } from "../../entities/IDayliStreak";
import { NumbersAnimatedOnUpdate } from '../unsorted/NumbersAnimatedOnUpdate';
import { IDayliStreak } from '../../entities/IDayliStreak';
import { NumbersAnimatedOnUpdate } from '../ui/NumbersAnimatedOnUpdate';

const useStyles = makeStyles((theme: Theme) => ({
successIcon: {
Expand Down
15 changes: 0 additions & 15 deletions src/components/tasks/TasksList/TasksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import React, { useState } from 'react';
import { When } from 'react-if';
import { tasksPerPage } from '../../../contants';
import { Task } from '../../../entities/Task';
import { useTypedSelector } from '../../../store/index';
import { tasksSelector } from '../../../store/selectors';
import { TasksListItem } from '../TasksListItem';

const log = debug('TasksList');
Expand Down Expand Up @@ -85,16 +83,3 @@ function useStyles() {
};
})();
}

// TODO #125 add props types
export default function TasksListContainer(props: any) {
const tasks = useTypedSelector(tasksSelector);

const mergeProps = {
...props,
tasks,
loading: tasks === undefined,
};

return <TasksList {...mergeProps} />;
}
1 change: 1 addition & 0 deletions src/components/tasks/TasksList/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TasksList';
19 changes: 19 additions & 0 deletions src/components/ui/EmotionIconButton/EmotionIconButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { sections } from '../../storybookContants';
import {
EmotionIconButton,
EmotionIconButtonProps,
} from '../EmotionIconButton';

export default {
component: EmotionIconButton,
title: `${sections.ui}EmotionIconButton`,
};

const props = {
type: 'happy_face',
onClick: console.log,
} as EmotionIconButtonProps;

export const Demo = (args) => <EmotionIconButton {...args} />;
Demo.args = props;
27 changes: 27 additions & 0 deletions src/components/ui/EmotionIconButton/EmotionIconButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Fab } from '@material-ui/core';
import React, { memo } from 'react';
import { Icon } from '../../ui/Icon';

export interface EmotionIconButtonProps {
type: 'happy_face' | 'sad_face';
color?: 'primary' | 'secondary';
onClick?: (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
) => void;
}

const EmotionIconButton = memo(function EmotionIconButton({
type,
color = 'secondary',
onClick,
}: EmotionIconButtonProps) {
return (
<Fab color={color} onClick={onClick}>
<Icon code={type} size="large" />
</Fab>
);
});

EmotionIconButton.displayName = 'EmotionIconButton';

export { EmotionIconButton };
1 change: 1 addition & 0 deletions src/components/ui/EmotionIconButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './EmotionIconButton';
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {

export default {
component: GlobalSnackbar,
title: `${sections.unsorted}GlobalSnackbar`,
title: `${sections.ui}GlobalSnackbar`,
};

const props = {
_isOpenForDevPurposes: true,
} as GlobalSnackbarProps;

export const Demo = args => <GlobalSnackbar {...args} />;
export const Demo = (args) => <GlobalSnackbar {...args} />;
Demo.args = props;
26 changes: 26 additions & 0 deletions src/components/ui/Icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { sections } from '../storybookContants';
import { Icon, IconProps } from './Icon';

export default {
component: Icon,
title: `${sections.ui}Icon`,
};

const props = {
code: 'happy_face',
} as IconProps;

export const Demo = (args) => (
<div>
<Icon code="happy_face" />
<Icon code="sad_face" />
<h2>Use controls to change: </h2>
<Icon {...args} />
<h2>Sizes: </h2>
<Icon {...args} size="small" />
<Icon {...args} size="default" />
<Icon {...args} size="big" />
</div>
);
Demo.args = props;
32 changes: 32 additions & 0 deletions src/components/ui/Icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Box } from '@material-ui/core';
import SatisfiedIcon from '@material-ui/icons/SentimentSatisfiedAlt';
import DissatisfiedIcon from '@material-ui/icons/SentimentVeryDissatisfied';
import React, { memo } from 'react';

export type Icons = 'happy_face' | 'sad_face';

export interface IconProps {
code: Icons;
size?: 'large' | 'small' | 'default';
}

const Icon = memo(function Icon({
code,
size = 'default',
}: IconProps) {
function getIconByCode() {
switch (code) {
case 'happy_face':
return <SatisfiedIcon fontSize={size} />;
case 'sad_face':
return <DissatisfiedIcon fontSize={size} />;
default:
return <SatisfiedIcon fontSize={size} />;
}
}
return <Box display="flex">{getIconByCode()}</Box>;
});

Icon.displayName = 'Icon';

export { Icon };
2 changes: 1 addition & 1 deletion src/components/ui/Sidebar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export default {
title: `${sections.ui}Sidebar`,
};

export const Normal = () => <Sidebar isOpen isLoggedIn isTasksListEmpty />;
export const Normal = () => <Sidebar isOpen isLoggedIn />;
20 changes: 20 additions & 0 deletions src/components/unsorted/Autocomplete/Autocomplete.stories.tsx
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;
92 changes: 92 additions & 0 deletions src/components/unsorted/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { Box, TextField } from '@material-ui/core';
import MuiAutocomplete, {
createFilterOptions,
} from '@material-ui/lab/Autocomplete';
import React, { memo } from 'react';

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,
) {
return (
<Box my={2}>
<MuiAutocomplete
freeSolo
clearOnBlur
selectOnFocus
handleHomeEndKeys
options={props.options}
renderOption={(i) => i.label}
filterOptions={(options, 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') {
return props.onChange(newValue);
}

// TODO: rename this.
if (newValue?.inputValue) {
newValue.label = newValue.inputValue;
}

props.onChange(newValue);
}}
/>
</Box>
);
});

Autocomplete.displayName = 'Autocomplete';

export { Autocomplete };
1 change: 1 addition & 0 deletions src/components/unsorted/Autocomplete/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Autocomplete';
13 changes: 0 additions & 13 deletions src/components/unsorted/MyUserPoints.stories.tsx

This file was deleted.

Loading