From 3e692e482e0751ce73cf24055a76b4fa337c0d3c Mon Sep 17 00:00:00 2001
From: newick
Date: Fri, 7 Jun 2019 11:28:55 +0200
Subject: [PATCH 01/19] style(Contribute): add form elements add intention
selector change cheap selector to efficient ones
---
.../CreateNoticeScreen.stories.tsx | 10 ++
.../App/CreateNoticeScreen/Textarea.tsx | 7 ++
.../content/App/CreateNoticeScreen/index.tsx | 29 ++++++
.../App/Notice/Details/Details.stories.tsx | 23 +++++
.../content/App/Notice/Details/withConnect.ts | 1 +
.../App/PublishedNoticeScreen/Container.ts | 21 +++++
.../App/PublishedNoticeScreen/Content.ts | 6 ++
.../App/PublishedNoticeScreen/ContentTitle.ts | 7 ++
.../PublishedNoticeScreen/Illustration.tsx | 91 +++++++++++++++++++
.../PublishedNoticeScreen.stories.tsx | 9 ++
.../App/PublishedNoticeScreen/index.tsx | 27 ++++++
src/app/theme.ts | 4 +-
src/components/atoms/ContentWrapper.ts | 6 ++
.../atoms/Forms/Error/Error.stories.tsx | 7 ++
src/components/atoms/Forms/Error/Error.ts | 9 ++
.../atoms/Forms/Input/Input.stories.tsx | 22 +++++
src/components/atoms/Forms/Input/Input.ts | 25 +++++
.../atoms/Forms/Textarea/Textarea.stories.tsx | 11 ++-
.../atoms/Forms/Textarea/Textarea.ts | 19 +++-
.../Type => atoms/Intentions}/Background.ts | 10 +-
.../atoms/Intentions/Intention.stories.tsx | 24 +++++
.../Intentions}/IntentionIcon.tsx | 11 ++-
src/components/atoms/icons/Alternative.tsx | 27 ++++++
src/components/atoms/icons/Information.tsx | 29 ++++++
src/components/atoms/icons/IntentionsIcons.ts | 21 +++++
src/components/atoms/icons/Other.tsx | 26 ++++++
.../{types/Dislike.tsx => ThumbDown.tsx} | 11 ++-
.../icons/{types/Like.tsx => ThumbUp.tsx} | 11 ++-
.../atoms/icons/types/Alternative.tsx | 13 ---
.../atoms/icons/types/Information.tsx | 15 ---
src/components/atoms/icons/types/Other.tsx | 14 ---
src/components/atoms/icons/types/index.ts | 22 -----
src/components/atoms/index.ts | 1 +
.../IntentionsSelector.stories.tsx | 10 ++
.../IntentionsSelector/IntentionsSelector.tsx | 22 +++++
.../IntentionsSelectorContainer.ts | 14 +++
.../molecules/Type/Type.stories.tsx | 13 ---
src/components/organisms/Notice/Notice.tsx | 6 +-
.../NoticeDetails/CenterContainer.ts | 11 +++
.../NoticeDetails/DetailsContainer.ts | 3 +
.../organisms/NoticeDetails/DetailsContent.ts | 2 +-
.../organisms/NoticeDetails/Feedbacks.ts | 3 +-
.../NoticeDetails/NoticeDetails.stories.tsx | 10 ++
.../organisms/NoticeDetails/NoticeDetails.tsx | 14 +--
44 files changed, 559 insertions(+), 118 deletions(-)
create mode 100644 src/app/content/App/CreateNoticeScreen/CreateNoticeScreen.stories.tsx
create mode 100644 src/app/content/App/CreateNoticeScreen/Textarea.tsx
create mode 100644 src/app/content/App/CreateNoticeScreen/index.tsx
create mode 100644 src/app/content/App/PublishedNoticeScreen/Container.ts
create mode 100644 src/app/content/App/PublishedNoticeScreen/Content.ts
create mode 100644 src/app/content/App/PublishedNoticeScreen/ContentTitle.ts
create mode 100644 src/app/content/App/PublishedNoticeScreen/Illustration.tsx
create mode 100644 src/app/content/App/PublishedNoticeScreen/PublishedNoticeScreen.stories.tsx
create mode 100644 src/app/content/App/PublishedNoticeScreen/index.tsx
create mode 100644 src/components/atoms/ContentWrapper.ts
create mode 100644 src/components/atoms/Forms/Error/Error.stories.tsx
create mode 100644 src/components/atoms/Forms/Error/Error.ts
create mode 100644 src/components/atoms/Forms/Input/Input.stories.tsx
create mode 100644 src/components/atoms/Forms/Input/Input.ts
rename src/components/{molecules/Type => atoms/Intentions}/Background.ts (66%)
create mode 100644 src/components/atoms/Intentions/Intention.stories.tsx
rename src/components/{molecules/Type => atoms/Intentions}/IntentionIcon.tsx (63%)
create mode 100644 src/components/atoms/icons/Alternative.tsx
create mode 100644 src/components/atoms/icons/Information.tsx
create mode 100644 src/components/atoms/icons/IntentionsIcons.ts
create mode 100644 src/components/atoms/icons/Other.tsx
rename src/components/atoms/icons/{types/Dislike.tsx => ThumbDown.tsx} (85%)
rename src/components/atoms/icons/{types/Like.tsx => ThumbUp.tsx} (86%)
delete mode 100644 src/components/atoms/icons/types/Alternative.tsx
delete mode 100644 src/components/atoms/icons/types/Information.tsx
delete mode 100644 src/components/atoms/icons/types/Other.tsx
delete mode 100644 src/components/atoms/icons/types/index.ts
create mode 100644 src/components/molecules/IntentionsSelector/IntentionsSelector.stories.tsx
create mode 100644 src/components/molecules/IntentionsSelector/IntentionsSelector.tsx
create mode 100644 src/components/molecules/IntentionsSelector/IntentionsSelectorContainer.ts
delete mode 100644 src/components/molecules/Type/Type.stories.tsx
create mode 100644 src/components/organisms/NoticeDetails/CenterContainer.ts
diff --git a/src/app/content/App/CreateNoticeScreen/CreateNoticeScreen.stories.tsx b/src/app/content/App/CreateNoticeScreen/CreateNoticeScreen.stories.tsx
new file mode 100644
index 000000000..38f91a25c
--- /dev/null
+++ b/src/app/content/App/CreateNoticeScreen/CreateNoticeScreen.stories.tsx
@@ -0,0 +1,10 @@
+import React from 'react';
+import { storiesOf } from '@storybook/react';
+import { action } from '@storybook/addon-actions';
+import { MemoryRouter as Router } from 'react-router-dom';
+import CreateNoticeScreen from '.';
+
+storiesOf('screens/CreateNotice', module)
+ .addDecorator(getStory => {getStory()})
+ .add('normal', () => )
+ .add('error', () => );
diff --git a/src/app/content/App/CreateNoticeScreen/Textarea.tsx b/src/app/content/App/CreateNoticeScreen/Textarea.tsx
new file mode 100644
index 000000000..740ce6a55
--- /dev/null
+++ b/src/app/content/App/CreateNoticeScreen/Textarea.tsx
@@ -0,0 +1,7 @@
+import React from 'react';
+import styled from 'styled-components';
+import Button from 'components/atoms/Forms/Textarea/Textarea';
+
+export default styled(Button)`
+ height: 154px;
+`;
diff --git a/src/app/content/App/CreateNoticeScreen/index.tsx b/src/app/content/App/CreateNoticeScreen/index.tsx
new file mode 100644
index 000000000..88cf21258
--- /dev/null
+++ b/src/app/content/App/CreateNoticeScreen/index.tsx
@@ -0,0 +1,29 @@
+import React from 'react';
+import Notification from 'components/organisms/Notification';
+import IntentionsSelector from 'components/molecules/IntentionsSelector/IntentionsSelector';
+import Input from 'components/atoms/Forms/Input/Input';
+import Textarea from './Textarea';
+import Error from 'components/atoms/Forms/Error/Error';
+import { CenterContainer, ContentWrapper } from 'components/atoms/';
+import BorderButton from 'components/atoms/Buttons/BorderButton';
+
+interface Props {
+ close: () => void;
+}
+export const CreateNoticeScreen = ({ close }: Props) => (
+
+
+
+
+
+
+
+ prévisualiser et publier
+
+
+ Les champs en rouge sont incorrects ou incomplets
+
+
+);
+
+export default CreateNoticeScreen;
diff --git a/src/app/content/App/Notice/Details/Details.stories.tsx b/src/app/content/App/Notice/Details/Details.stories.tsx
index 7c7db7a88..982b4286c 100644
--- a/src/app/content/App/Notice/Details/Details.stories.tsx
+++ b/src/app/content/App/Notice/Details/Details.stories.tsx
@@ -54,4 +54,27 @@ storiesOf('screens/Notice/Details', module)
view={action('view')}
followSource={action('followSource')}
/>
+ ))
+ .add('preview', () => (
+ ${text('message', defaultMessage)}
`,
+ sourceUrl: text('source', defaultSourceUrl),
+ created: date('created', defaultDate),
+ likes: number('likes', 42),
+ dislikes: number('dislikes', 2),
+ liked: boolean('liked', false),
+ disliked: boolean('disliked', false)
+ })}
+ like={action('like')}
+ unlike={action('unlike')}
+ dislike={action('dislike')}
+ undislike={action('undislike')}
+ view={action('view')}
+ followSource={action('followSource')}
+ close={action('close')}
+ preview
+ />
));
diff --git a/src/app/content/App/Notice/Details/withConnect.ts b/src/app/content/App/Notice/Details/withConnect.ts
index 3e5ff4dd6..87a5a2ccf 100644
--- a/src/app/content/App/Notice/Details/withConnect.ts
+++ b/src/app/content/App/Notice/Details/withConnect.ts
@@ -16,6 +16,7 @@ import { StatefulNotice } from '../../../../lmem/notice';
export interface DetailsStateProps {
notice?: StatefulNotice;
+ preview?: boolean;
}
const mapStateToProps = (
diff --git a/src/app/content/App/PublishedNoticeScreen/Container.ts b/src/app/content/App/PublishedNoticeScreen/Container.ts
new file mode 100644
index 000000000..e8407970e
--- /dev/null
+++ b/src/app/content/App/PublishedNoticeScreen/Container.ts
@@ -0,0 +1,21 @@
+import styled from 'styled-components';
+import { CenterContainer, ExternalLink } from 'components/atoms/';
+
+export default styled.article`
+ box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ height: 100%;
+ padding-bottom: 38px;
+ text-align: center;
+
+ & ${CenterContainer} {
+ margin-top: auto;
+ }
+
+ & ${ExternalLink} {
+ display: block;
+ font-weight: bold;
+ }
+`;
diff --git a/src/app/content/App/PublishedNoticeScreen/Content.ts b/src/app/content/App/PublishedNoticeScreen/Content.ts
new file mode 100644
index 000000000..7d5d98b3d
--- /dev/null
+++ b/src/app/content/App/PublishedNoticeScreen/Content.ts
@@ -0,0 +1,6 @@
+import styled from 'styled-components';
+
+export default styled.p`
+ font-size: 14px;
+ margin: 5px 0 20px;
+`;
diff --git a/src/app/content/App/PublishedNoticeScreen/ContentTitle.ts b/src/app/content/App/PublishedNoticeScreen/ContentTitle.ts
new file mode 100644
index 000000000..610acbcd5
--- /dev/null
+++ b/src/app/content/App/PublishedNoticeScreen/ContentTitle.ts
@@ -0,0 +1,7 @@
+import styled from 'styled-components';
+import ContentTitle from 'components/atoms/ContentTitle';
+
+export default styled(ContentTitle)`
+ margin-top: 9px;
+ font-size: 22px;
+`;
diff --git a/src/app/content/App/PublishedNoticeScreen/Illustration.tsx b/src/app/content/App/PublishedNoticeScreen/Illustration.tsx
new file mode 100644
index 000000000..bfdd89fa0
--- /dev/null
+++ b/src/app/content/App/PublishedNoticeScreen/Illustration.tsx
@@ -0,0 +1,91 @@
+import React from 'react';
+
+export default () => (
+
+);
diff --git a/src/app/content/App/PublishedNoticeScreen/PublishedNoticeScreen.stories.tsx b/src/app/content/App/PublishedNoticeScreen/PublishedNoticeScreen.stories.tsx
new file mode 100644
index 000000000..71ae9b7fc
--- /dev/null
+++ b/src/app/content/App/PublishedNoticeScreen/PublishedNoticeScreen.stories.tsx
@@ -0,0 +1,9 @@
+import React from 'react';
+import { storiesOf } from '@storybook/react';
+import { action } from '@storybook/addon-actions';
+import { MemoryRouter as Router } from 'react-router-dom';
+import PublishedNoticeScreen from '.';
+
+storiesOf('screens/PublishedNotice', module)
+ .addDecorator(getStory => {getStory()})
+ .add('normal', () => );
diff --git a/src/app/content/App/PublishedNoticeScreen/index.tsx b/src/app/content/App/PublishedNoticeScreen/index.tsx
new file mode 100644
index 000000000..69994061e
--- /dev/null
+++ b/src/app/content/App/PublishedNoticeScreen/index.tsx
@@ -0,0 +1,27 @@
+import React from 'react';
+
+import Notification from 'components/organisms/Notification';
+import { Button, CenterContainer, ExternalLink } from 'components/atoms';
+import BorderButton from 'components/atoms/Buttons/BorderButton';
+import Container from './Container';
+import Content from './Content';
+import ContentTitle from './ContentTitle';
+import Illustration from './Illustration';
+
+export default () => (
+
+
+
+ Félicitations !
+
+ Votre bulle sera publiée d’ici 24h sur :
+ www.ouisncf.com
+
+ Voir la Bulle
+
+
+
+
+
+
+);
diff --git a/src/app/theme.ts b/src/app/theme.ts
index 38937cd61..850c42e8c 100644
--- a/src/app/theme.ts
+++ b/src/app/theme.ts
@@ -23,7 +23,7 @@ export interface Theme {
accountListBg: string;
// color list:
- typeBg: string;
+ inactiveIntentionBg: string;
bottomBar: string;
topBarNavInactiveDeleteBg: string;
formBorder: string;
@@ -97,7 +97,7 @@ export const theme: Theme = {
accountListBg: '#fff',
// color list:
- typeBg: '#EBEBEB',
+ inactiveIntentionBg: '#EBEBEB',
bottomBar: '#DDDDDD',
topBarNavInactiveDeleteBg: '#A6B1C0',
formBorder: '#707070',
diff --git a/src/components/atoms/ContentWrapper.ts b/src/components/atoms/ContentWrapper.ts
new file mode 100644
index 000000000..f5989fc37
--- /dev/null
+++ b/src/components/atoms/ContentWrapper.ts
@@ -0,0 +1,6 @@
+import styled from 'styled-components';
+
+export default styled.section`
+ box-sizing: border-box;
+ padding: 11px 19px;
+`;
diff --git a/src/components/atoms/Forms/Error/Error.stories.tsx b/src/components/atoms/Forms/Error/Error.stories.tsx
new file mode 100644
index 000000000..4c65f488b
--- /dev/null
+++ b/src/components/atoms/Forms/Error/Error.stories.tsx
@@ -0,0 +1,7 @@
+import React from 'react';
+import { storiesOf } from '@storybook/react';
+import Error from './Error';
+
+storiesOf('atoms/Forms/Error Text', module).add('text', () => (
+ Les champs en rouge sont incorrects ou incomplets
+));
diff --git a/src/components/atoms/Forms/Error/Error.ts b/src/components/atoms/Forms/Error/Error.ts
new file mode 100644
index 000000000..b5b460d0b
--- /dev/null
+++ b/src/components/atoms/Forms/Error/Error.ts
@@ -0,0 +1,9 @@
+import styled from 'styled-components';
+
+export default styled.p`
+ font-size: 13px;
+ line-height: 1;
+ color: ${props => props.theme.formError};
+ font-weight: bold;
+ text-align: center;
+`;
diff --git a/src/components/atoms/Forms/Input/Input.stories.tsx b/src/components/atoms/Forms/Input/Input.stories.tsx
new file mode 100644
index 000000000..e1ca9f1f4
--- /dev/null
+++ b/src/components/atoms/Forms/Input/Input.stories.tsx
@@ -0,0 +1,22 @@
+import React from 'react';
+import { storiesOf } from '@storybook/react';
+import Input from './Input';
+
+storiesOf('atoms/Forms/Input', module)
+ .add('text', () => (
+
+ ))
+ .add('text with error', () => (
+
+ ))
+ .add('email', () => )
+ .add('email with error', () => (
+
+ ));
diff --git a/src/components/atoms/Forms/Input/Input.ts b/src/components/atoms/Forms/Input/Input.ts
new file mode 100644
index 000000000..021272d74
--- /dev/null
+++ b/src/components/atoms/Forms/Input/Input.ts
@@ -0,0 +1,25 @@
+import styled from 'styled-components';
+
+interface Props {
+ error?: boolean;
+}
+
+export default styled.input`
+ box-sizing: border-box;
+ width: 100%;
+ margin-bottom: 10px;
+ padding: 8px 10px 10px 14px;
+ font-size: 13px;
+ line-height: 1;
+ border-radius: 6px;
+ border: 1px solid
+ ${props =>
+ props.error ? props.theme.formError : props.theme.secondaryColor};
+ box-shadow: inset 0px 0px 0px 2px
+ ${props => (props.error ? props.theme.formError : '#fff')};
+ resize: none;
+
+ ::placeholder {
+ font-style: italic;
+ }
+`;
diff --git a/src/components/atoms/Forms/Textarea/Textarea.stories.tsx b/src/components/atoms/Forms/Textarea/Textarea.stories.tsx
index c05efa749..d5222a07e 100644
--- a/src/components/atoms/Forms/Textarea/Textarea.stories.tsx
+++ b/src/components/atoms/Forms/Textarea/Textarea.stories.tsx
@@ -2,4 +2,13 @@ import React from 'react';
import { storiesOf } from '@storybook/react';
import Textarea from './Textarea';
-storiesOf('atoms/Forms/Textarea', module).add('normal', () => );
+storiesOf('atoms/Forms/Textarea', module)
+ .add('normal', () => (
+
+ ))
+ .add('error', () => (
+
+ ));
diff --git a/src/components/atoms/Forms/Textarea/Textarea.ts b/src/components/atoms/Forms/Textarea/Textarea.ts
index 99ba2658e..de61dda89 100644
--- a/src/components/atoms/Forms/Textarea/Textarea.ts
+++ b/src/components/atoms/Forms/Textarea/Textarea.ts
@@ -1,14 +1,25 @@
import styled from 'styled-components';
-export default styled.textarea`
+interface Props {
+ error?: boolean;
+}
+
+export default styled.textarea`
box-sizing: border-box;
width: 100%;
height: 87px;
margin-bottom: 10px;
- padding: 10px;
+ padding: 8px 10px 10px 14px;
font-size: 13px;
border-radius: 6px;
- border: 1px solid ${props => props.theme.secondaryColor};
+ border: 1px solid
+ ${props =>
+ props.error ? props.theme.formError : props.theme.secondaryColor};
+ box-shadow: inset 0px 0px 0px 2px
+ ${props => (props.error ? props.theme.formError : '#fff')};
resize: none;
- font-style: italic;
+
+ ::placeholder {
+ font-style: italic;
+ }
`;
diff --git a/src/components/molecules/Type/Background.ts b/src/components/atoms/Intentions/Background.ts
similarity index 66%
rename from src/components/molecules/Type/Background.ts
rename to src/components/atoms/Intentions/Background.ts
index faa7e7e69..437ef40f7 100644
--- a/src/components/molecules/Type/Background.ts
+++ b/src/components/atoms/Intentions/Background.ts
@@ -1,6 +1,6 @@
import styled from 'styled-components';
-const TypeBackground = styled.div`
+const IntentionBackground = styled.div`
display: flex;
justify-content: center;
align-items: center;
@@ -9,14 +9,10 @@ const TypeBackground = styled.div`
margin-right: 10px;
border-radius: 50%;
background-color: ${props => props.color};
-
- & > svg {
- fill: #fff;
- }
`;
-TypeBackground.defaultProps = {
+IntentionBackground.defaultProps = {
color: '#F1F1F4'
};
-export default TypeBackground;
+export default IntentionBackground;
diff --git a/src/components/atoms/Intentions/Intention.stories.tsx b/src/components/atoms/Intentions/Intention.stories.tsx
new file mode 100644
index 000000000..b5f558dad
--- /dev/null
+++ b/src/components/atoms/Intentions/Intention.stories.tsx
@@ -0,0 +1,24 @@
+import React from 'react';
+import { MemoryRouter as Router } from 'react-router-dom';
+import { storiesOf } from '@storybook/react';
+import Intention from './IntentionIcon';
+
+storiesOf('atoms/Intentions', module)
+ .addDecorator(getStory => {getStory()})
+ .add('approval (active)', () => )
+ .add('approval (inactive)', () => )
+ .add('disapproval (active)', () => (
+
+ ))
+ .add('disapproval (inactive)', () => )
+ .add('alternative (active)', () => (
+
+ ))
+ .add('alternative (inactive)', () => )
+ .add('information (active)', () => (
+
+ ))
+ .add('information (inactive)', () => )
+ .add('other (active)', () => )
+ .add('other (inactive)', () => )
+ .add('undefined / unknown ', () => );
diff --git a/src/components/molecules/Type/IntentionIcon.tsx b/src/components/atoms/Intentions/IntentionIcon.tsx
similarity index 63%
rename from src/components/molecules/Type/IntentionIcon.tsx
rename to src/components/atoms/Intentions/IntentionIcon.tsx
index e1f9c99c3..2d06d9f50 100644
--- a/src/components/molecules/Type/IntentionIcon.tsx
+++ b/src/components/atoms/Intentions/IntentionIcon.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { withTheme } from 'styled-components';
import Background from './Background';
-import intentionIcons from '../../atoms/icons/types';
+import intentionIcons from '../icons/IntentionsIcons';
import { Theme } from 'app/theme';
import { getTypeOrFallback, Intention } from 'app/lmem/intention';
@@ -11,14 +11,17 @@ interface Style {
interface Props {
intention?: Intention;
theme: Theme;
+ active?: boolean;
}
-const IntentionIcon = ({ intention, theme }: Props) => {
+const IntentionIcon = ({ intention, theme, active }: Props) => {
const Icon = getTypeOrFallback(intentionIcons)(intention);
const style = getTypeOrFallback