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

fix: StatusIndicator spacing and flexbox bug #584

Merged
merged 5 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 19 additions & 9 deletions components/src/StatusIndicator/StatusIndicator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from "prop-types";
import styled from "styled-components";
import { space } from "styled-system";
import { space, typography, flexbox } from "styled-system";
import propTypes from "@styled-system/prop-types";
import theme from "../theme";

Expand Down Expand Up @@ -44,27 +44,37 @@ const getStatusIndicatorColours = type => {
const StatusIndicator = styled.p(
{
display: "inline-block",
fontSize: theme.fontSizes.smaller,
lineHeight: theme.lineHeights.smallerText,
fontWeight: theme.fontWeights.bold,
textTransform: "uppercase",
letterSpacing: ".05em",
padding: `0 ${theme.space.x1}`,
borderRadius: theme.space.x1,
position: "relative",
top: "-2px"
borderRadius: theme.space.x1
},
space,
typography,
flexbox,
({ type }) => getStatusIndicatorColours(type)
);

StatusIndicator.propTypes = {
type: PropTypes.oneOf(["neutral", "danger", "informative", "success", "warning", "quiet"]),
...propTypes.space
...propTypes.space,
...propTypes.typography,
...propTypes.flexbox
};

StatusIndicator.defaultProps = {
type: "neutral"
type: "neutral",
mt: "0",
mr: "0",
mb: "0",
ml: "0",
pt: "0",
pr: "x1",
pb: "0",
pl: "x1",
fontSize: "smaller",
lineHeight: "smallerText",
alignSelf: "center"
};

export default StatusIndicator;
58 changes: 51 additions & 7 deletions components/src/StatusIndicator/StatusIndicator.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { storiesOf } from "@storybook/react";
import { StatusIndicator } from ".";
import { Text, SectionTitle, SubsectionTitle } from "../Type";
import { Box } from "../Box";
import { Flex } from "../Flex";

storiesOf("StatusIndicator", module)
.add("All", () => (
Expand Down Expand Up @@ -36,35 +37,78 @@ storiesOf("StatusIndicator", module)
.add("Danger", () => <StatusIndicator type="danger">Danger</StatusIndicator>)
.add("Following text", () => (
<>
<Box m="x3">
<Box mb="x3">
<SectionTitle inline mr="x1">
Label
</SectionTitle>
<StatusIndicator>Status</StatusIndicator>
</Box>
<Box m="x3">
<Box mb="x3">
<SubsectionTitle inline mr="x1">
Label
</SubsectionTitle>
<StatusIndicator>Status</StatusIndicator>
</Box>
<Box m="x3">
<Box mb="x3">
<Text inline mr="x1">
Label
</Text>
<StatusIndicator>Status</StatusIndicator>
</Box>
<Box m="x3">
<Text fontSize="small" inline mr="x1">
<Box mb="x3">
<Text fontSize="small" lineHeight="smallTextBase" inline mr="x1">
Label
</Text>
<StatusIndicator>Status</StatusIndicator>
</Box>
<Box m="x3">
<Text fontSize="smaller" inline mr="x1">
<Box mb="x3">
<Text fontSize="smaller" lineHeight="smallerText" inline mr="x1">
Label
</Text>
<StatusIndicator>Status</StatusIndicator>
</Box>
<Box mb="x3">
<Text inline mr="x1">
Long label Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus in eleifend metus, in tempus
sapien. Morbi eget felis est. Nunc facilisis vel nisi nec ornare. Ut blandit ullamcorper enim sed fringilla.
Quisque malesuada pharetra tincidunt. Mauris mauris tortor, maximus vitae tempor ac, tincidunt pharetra augue.
In eget suscipit est. Suspendisse feugiat risus urna
</Text>
<StatusIndicator>Status</StatusIndicator>
</Box>
</>
))
.add("Inside flex", () => (
<>
<Flex mb="x3">
<SectionTitle inline mr="x1" mb="0">
Label
</SectionTitle>
<StatusIndicator>Status</StatusIndicator>
</Flex>
<Flex mb="x3">
<SubsectionTitle inline mr="x1" mb="0">
Label
</SubsectionTitle>
<StatusIndicator>Status</StatusIndicator>
</Flex>
<Flex mb="x3">
<Text inline mr="x1" mb="0">
Label
</Text>
<StatusIndicator>Status</StatusIndicator>
</Flex>
<Flex mb="x3">
<Text fontSize="small" lineHeight="smallTextBase" inline mr="x1" mb="0">
Label
</Text>
<StatusIndicator>Status</StatusIndicator>
</Flex>
<Flex mb="x3">
<Text fontSize="smaller" lineHeight="smallerText" inline mr="x1" mb="0">
Label
</Text>
<StatusIndicator>Status</StatusIndicator>
</Flex>
</>
));
Loading