saleor-dashboard/src/components/Timeline/Timeline.tsx

135 lines
3.2 KiB
TypeScript
Raw Normal View History

import { Avatar, Button, CardContent, TextField } from "@material-ui/core";
2019-06-19 14:40:52 +00:00
import deepPurple from "@material-ui/core/colors/deepPurple";
import PersonIcon from "@material-ui/icons/Person";
Use MacawUI (#1229) * Replace withStyleswith useStyles (#1100) * Replace withStyleswith useStyles * Update messages * Use rem as a spacing unit (#1101) * Use rems as spacing units * Fix visual bugs * Update stories * Use macaw-ui as theme provider (#1108) * Use macaw ui as a theme provider * Add react-dom to aliases * Fix jest module resolution * Update useTheme hook usage * Fix test wrapper * Use macaw from git repo * Fix CI * Update stories * Fix aliasing * Extract savebar to macaw ui (#1146) * wip * Use savebar from macaw * Use confirm button from macaw * Improve file structure * Use sidebar context from macaw * Update macaw * Update macaw version * Remove savebar from storybook * Update stories * Use alerts and notifications from macaw (#1166) * Use alerts from macaw * Add notifications from macaw * Update stories * Pin macaw version * Encapsulate limit reached in one component * Remove unused imports * Use backlinks from macaw (#1183) * Use backlink from macaw * Update macaw version * Use macaw sidebar (#1148) * Use sidebar from macaw * Use shipped logo * Use lowercase * Update stories * Use user chip from macaw (#1191) * Use user chip from macaw * Use dedicated components for menu items * Simplify code * Bump version and fix types (#1210) * Rename onBack to onClick * Rename UserChip to UserChipMenu * Rename IMenuItem to SidebarMenuItem * Update macaw version * Fix tables after changes in macaw (#1220) * Update macaw version * Update changelog * Update stories * Fix after rebase * Update to macaw 0.2.0 * Lint files * Update macaw to 0.2.2
2021-07-21 08:59:52 +00:00
import { makeStyles } from "@saleor/macaw-ui";
2019-08-09 10:26:22 +00:00
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
2019-06-19 14:40:52 +00:00
2019-10-30 14:34:24 +00:00
const useStyles = makeStyles(
theme => ({
2019-06-19 14:40:52 +00:00
avatar: {
"& span": {
height: "100%",
width: "100%"
},
alignSelf: "flex-start",
2019-10-28 16:16:49 +00:00
marginRight: theme.spacing(3.5)
},
button: {
zIndex: 2
2019-06-19 14:40:52 +00:00
},
cardActionsExpanded: {
2019-10-28 16:16:49 +00:00
maxHeight: theme.spacing(6)
2019-06-19 14:40:52 +00:00
},
input: {
2019-09-04 12:38:58 +00:00
"& > div": {
padding: "0 14px"
},
"& textarea": {
"&::placeholder": {
opacity: [[1], "!important"] as any
2019-10-28 16:16:49 +00:00
},
zIndex: 2
2019-09-04 12:38:58 +00:00
},
2019-09-10 15:17:58 +00:00
background: theme.palette.background.paper
2019-06-19 14:40:52 +00:00
},
noteRoot: {
Use MacawUI (#1229) * Replace withStyleswith useStyles (#1100) * Replace withStyleswith useStyles * Update messages * Use rem as a spacing unit (#1101) * Use rems as spacing units * Fix visual bugs * Update stories * Use macaw-ui as theme provider (#1108) * Use macaw ui as a theme provider * Add react-dom to aliases * Fix jest module resolution * Update useTheme hook usage * Fix test wrapper * Use macaw from git repo * Fix CI * Update stories * Fix aliasing * Extract savebar to macaw ui (#1146) * wip * Use savebar from macaw * Use confirm button from macaw * Improve file structure * Use sidebar context from macaw * Update macaw * Update macaw version * Remove savebar from storybook * Update stories * Use alerts and notifications from macaw (#1166) * Use alerts from macaw * Add notifications from macaw * Update stories * Pin macaw version * Encapsulate limit reached in one component * Remove unused imports * Use backlinks from macaw (#1183) * Use backlink from macaw * Update macaw version * Use macaw sidebar (#1148) * Use sidebar from macaw * Use shipped logo * Use lowercase * Update stories * Use user chip from macaw (#1191) * Use user chip from macaw * Use dedicated components for menu items * Simplify code * Bump version and fix types (#1210) * Rename onBack to onClick * Rename UserChip to UserChipMenu * Rename IMenuItem to SidebarMenuItem * Update macaw version * Fix tables after changes in macaw (#1220) * Update macaw version * Update changelog * Update stories * Fix after rebase * Update to macaw 0.2.0 * Lint files * Update macaw to 0.2.2
2021-07-21 08:59:52 +00:00
left: theme.spacing(-8.5),
2019-10-28 16:16:49 +00:00
marginBottom: theme.spacing(3),
2019-06-19 14:40:52 +00:00
position: "relative",
Use MacawUI (#1229) * Replace withStyleswith useStyles (#1100) * Replace withStyleswith useStyles * Update messages * Use rem as a spacing unit (#1101) * Use rems as spacing units * Fix visual bugs * Update stories * Use macaw-ui as theme provider (#1108) * Use macaw ui as a theme provider * Add react-dom to aliases * Fix jest module resolution * Update useTheme hook usage * Fix test wrapper * Use macaw from git repo * Fix CI * Update stories * Fix aliasing * Extract savebar to macaw ui (#1146) * wip * Use savebar from macaw * Use confirm button from macaw * Improve file structure * Use sidebar context from macaw * Update macaw * Update macaw version * Remove savebar from storybook * Update stories * Use alerts and notifications from macaw (#1166) * Use alerts from macaw * Add notifications from macaw * Update stories * Pin macaw version * Encapsulate limit reached in one component * Remove unused imports * Use backlinks from macaw (#1183) * Use backlink from macaw * Update macaw version * Use macaw sidebar (#1148) * Use sidebar from macaw * Use shipped logo * Use lowercase * Update stories * Use user chip from macaw (#1191) * Use user chip from macaw * Use dedicated components for menu items * Simplify code * Bump version and fix types (#1210) * Rename onBack to onClick * Rename UserChip to UserChipMenu * Rename IMenuItem to SidebarMenuItem * Update macaw version * Fix tables after changes in macaw (#1220) * Update macaw version * Update changelog * Update stories * Fix after rebase * Update to macaw 0.2.0 * Lint files * Update macaw to 0.2.2
2021-07-21 08:59:52 +00:00
width: `calc(100% + ${theme.spacing(8.5)})`
2019-06-19 14:40:52 +00:00
},
noteTitle: {
"&:last-child": {
2019-09-04 12:38:58 +00:00
paddingBottom: 0,
paddingRight: 0
2019-06-19 14:40:52 +00:00
},
alignItems: "center",
background: theme.palette.background.default,
2019-09-02 08:44:26 +00:00
display: "flex",
2019-10-28 16:16:49 +00:00
paddingLeft: theme.spacing(3)
2019-06-19 14:40:52 +00:00
},
root: {
2019-10-30 14:34:24 +00:00
borderColor: theme.palette.divider,
2019-06-19 14:40:52 +00:00
borderStyle: "solid",
borderWidth: "0 0 0 2px",
marginLeft: 20,
2019-10-28 16:16:49 +00:00
paddingLeft: theme.spacing(3)
2019-06-19 14:40:52 +00:00
}
2019-10-30 14:34:24 +00:00
}),
{ name: "Timeline" }
);
2019-06-19 14:40:52 +00:00
2019-10-30 14:34:24 +00:00
interface TimelineProps {
2019-06-19 14:40:52 +00:00
children?: React.ReactNode;
}
2019-10-30 14:34:24 +00:00
interface TimelineAddNoteProps {
2019-06-19 14:40:52 +00:00
message: string;
2019-10-22 12:28:39 +00:00
reset: () => void;
2019-06-19 14:40:52 +00:00
onChange(event: React.ChangeEvent<any>);
onSubmit(event: React.FormEvent<any>);
}
2019-10-30 14:34:24 +00:00
export const Timeline: React.FC<TimelineProps> = props => {
const { children } = props;
2019-06-19 14:40:52 +00:00
2019-10-30 14:34:24 +00:00
const classes = useStyles(props);
2019-10-30 14:34:24 +00:00
return <div className={classes.root}>{children}</div>;
};
export const TimelineAddNote: React.FC<TimelineAddNoteProps> = props => {
const { message, onChange, onSubmit, reset } = props;
const classes = useStyles(props);
const intl = useIntl();
const submit = e => {
reset();
onSubmit(e);
};
return (
<div className={classes.noteRoot}>
<CardContent className={classes.noteTitle}>
<Avatar
style={{ background: deepPurple[500] }}
className={classes.avatar}
>
<PersonIcon />
</Avatar>
<TextField
className={classes.input}
placeholder={intl.formatMessage({
defaultMessage: "Leave your note here..."
})}
onChange={onChange}
value={message}
name="message"
fullWidth
multiline
InputProps={{
endAdornment: (
<Button
className={classes.button}
color="primary"
onClick={e => submit(e)}
>
<FormattedMessage
defaultMessage="Send"
description="add order note, button"
/>
</Button>
)
}}
variant="outlined"
/>
</CardContent>
</div>
);
};
2019-10-22 12:28:39 +00:00
2019-06-19 14:40:52 +00:00
Timeline.displayName = "Timeline";
export default Timeline;