Skip to content

Commit

Permalink
[Timeline] Add support for position override on items (#25974)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonecervini authored Apr 29, 2021
1 parent 2c7d5fe commit c7da2a5
Show file tree
Hide file tree
Showing 35 changed files with 280 additions and 136 deletions.
2 changes: 1 addition & 1 deletion docs/pages/api-docs/timeline-content.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"name": "TimelineContent",
"styles": {
"classes": ["root", "alignRight", "alignLeft", "alignAlternate"],
"classes": ["root", "positionRight", "positionLeft", "positionAlternate"],
"globalClasses": {},
"name": "MuiTimelineContent"
},
Expand Down
9 changes: 8 additions & 1 deletion docs/pages/api-docs/timeline-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
"props": {
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"position": { "type": { "name": "enum", "description": "'left'<br>&#124;&nbsp;'right'" } },
"sx": { "type": { "name": "object" } }
},
"name": "TimelineItem",
"styles": {
"classes": ["root", "alignLeft", "alignRight", "alignAlternate", "missingOppositeContent"],
"classes": [
"root",
"positionLeft",
"positionRight",
"positionAlternate",
"missingOppositeContent"
],
"globalClasses": {},
"name": "MuiTimelineItem"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/timeline-opposite-content.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"name": "TimelineOppositeContent",
"styles": {
"classes": ["root", "alignRight", "alignLeft", "alignAlternate"],
"classes": ["root", "positionRight", "positionLeft", "positionAlternate"],
"globalClasses": {},
"name": "MuiTimelineOppositeContent"
},
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/api-docs/timeline.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"props": {
"align": {
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"className": { "type": { "name": "string" } },
"position": {
"type": {
"name": "enum",
"description": "'alternate'<br>&#124;&nbsp;'left'<br>&#124;&nbsp;'right'"
},
"default": "'left'"
"default": "'right'"
},
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"className": { "type": { "name": "string" } },
"sx": { "type": { "name": "object" } }
},
"name": "Timeline",
"styles": {
"classes": ["root", "alignLeft", "alignRight", "alignAlternate"],
"classes": ["root", "positionLeft", "positionRight", "positionAlternate"],
"globalClasses": {},
"name": "MuiTimeline"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/AlternateTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';

export default function AlternateTimeline() {
return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/AlternateTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';

export default function AlternateTimeline() {
return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/ColorsTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';

export default function ColorsTimeline() {
return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/ColorsTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';

export default function ColorsTimeline() {
return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/CustomizedTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function CustomizedTimeline() {
const classes = useStyles();

return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineOppositeContent
className={classes.verticallyCenterContent}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/CustomizedTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function CustomizedTimeline() {
const classes = useStyles();

return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineOppositeContent
className={classes.verticallyCenterContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import TimelineConnector from '@material-ui/lab/TimelineConnector';
import TimelineContent from '@material-ui/lab/TimelineContent';
import TimelineDot from '@material-ui/lab/TimelineDot';

export default function RightAlignedTimeline() {
export default function LeftPositionedTimeline() {
return (
<Timeline align="right">
<Timeline position="left">
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import TimelineConnector from '@material-ui/lab/TimelineConnector';
import TimelineContent from '@material-ui/lab/TimelineContent';
import TimelineDot from '@material-ui/lab/TimelineDot';

export default function RightAlignedTimeline() {
export default function LeftPositionedTimeline() {
return (
<Timeline align="right">
<Timeline position="left">
<TimelineItem>
<TimelineSeparator>
<TimelineDot />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TimelineOppositeContent from '@material-ui/lab/TimelineOppositeContent';
export default function OppositeContentTimeline() {
return (
<React.Fragment>
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineOppositeContent color="text.secondary">
09:30 am
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TimelineOppositeContent from '@material-ui/lab/TimelineOppositeContent';
export default function OppositeContentTimeline() {
return (
<React.Fragment>
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineOppositeContent color="text.secondary">
09:30 am
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/OutlinedTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';

export default function OutlinedTimeline() {
return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineSeparator>
<TimelineDot variant="outlined" />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/timeline/OutlinedTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimelineDot from '@material-ui/lab/TimelineDot';

export default function OutlinedTimeline() {
return (
<Timeline align="alternate">
<Timeline position="alternate">
<TimelineItem>
<TimelineSeparator>
<TimelineDot variant="outlined" />
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/timeline/timeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ A basic timeline showing list of events.

{{"demo": "pages/components/timeline/BasicTimeline.js"}}

## Right-aligned timeline
## Left-positioned timeline

The timeline can be positioned on the right side of the events.
The main content of the timeline can be positioned on the left side relative to the time axis.

{{"demo": "pages/components/timeline/RightAlignedTimeline.js"}}
{{"demo": "pages/components/timeline/LeftPositionedTimeline.js"}}

## Alternating timeline

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
},
"classDescriptions": {
"root": { "description": "Styles applied to the root element." },
"alignRight": {
"positionRight": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"right\"</code>"
"conditions": "<code>position=\"right\"</code>"
},
"alignLeft": {
"positionLeft": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"left\"</code>"
"conditions": "<code>position=\"left\"</code>"
},
"alignAlternate": {
"positionAlternate": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"alternate\"</code>"
"conditions": "<code>position=\"alternate\"</code>"
}
}
}
13 changes: 7 additions & 6 deletions docs/translations/api-docs/timeline-item/timeline-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
"propDescriptions": {
"children": "The content of the component.",
"classes": "Override or extend the styles applied to the component. See <a href=\"#css\">CSS API</a> below for more details.",
"position": "The position where the timeline&#39;s item should appear.",
"sx": "The system prop that allows defining system overrides as well as additional CSS styles. See the <a href=\"/system/basics/#the-sx-prop\">`sx` page</a> for more details."
},
"classDescriptions": {
"root": { "description": "Styles applied to the root element." },
"alignLeft": {
"positionLeft": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"left\"</code>"
"conditions": "<code>position=\"left\"</code>"
},
"alignRight": {
"positionRight": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"right\"</code>"
"conditions": "<code>position=\"right\"</code>"
},
"alignAlternate": {
"positionAlternate": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"alternate\"</code>"
"conditions": "<code>position=\"alternate\"</code>"
},
"missingOppositeContent": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
},
"classDescriptions": {
"root": { "description": "Styles applied to the root element." },
"alignRight": {
"positionRight": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"right\"</code>"
"conditions": "<code>position=\"right\"</code>"
},
"alignLeft": {
"positionLeft": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"left\"</code>"
"conditions": "<code>position=\"left\"</code>"
},
"alignAlternate": {
"positionAlternate": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"alternate\"</code>"
"conditions": "<code>position=\"alternate\"</code>"
}
}
}
14 changes: 7 additions & 7 deletions docs/translations/api-docs/timeline/timeline.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"componentDescription": "",
"propDescriptions": {
"align": "The position where the timeline&#39;s content should appear.",
"children": "The content of the component.",
"classes": "Override or extend the styles applied to the component. See <a href=\"#css\">CSS API</a> below for more details.",
"className": "className applied to the root element.",
"position": "The position where the TimelineContent should appear relative to the time axis.",
"sx": "The system prop that allows defining system overrides as well as additional CSS styles. See the <a href=\"/system/basics/#the-sx-prop\">`sx` page</a> for more details."
},
"classDescriptions": {
"root": { "description": "Styles applied to the root element." },
"alignLeft": {
"positionLeft": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"left\"</code>"
"conditions": "<code>position=\"left\"</code>"
},
"alignRight": {
"positionRight": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"right\"</code>"
"conditions": "<code>position=\"right\"</code>"
},
"alignAlternate": {
"positionAlternate": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>align=\"alternate\"</code>"
"conditions": "<code>position=\"alternate\"</code>"
}
}
}
4 changes: 2 additions & 2 deletions packages/material-ui-lab/src/Timeline/Timeline.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('<Timeline />', () => {
render,
muiName: 'MuiTimeline',
refInstanceof: window.HTMLUListElement,
testVariantProps: { align: 'right' },
testStateOverrides: { prop: 'align', value: 'right', styleKey: 'alignRight' },
testVariantProps: { position: 'left' },
testStateOverrides: { prop: 'position', value: 'left', styleKey: 'positionLeft' },
skip: ['componentProp', 'componentsProp'],
}));
});
Loading

0 comments on commit c7da2a5

Please sign in to comment.