@kiwicom/orbit-components
Version:
<div align="center"> <a href="https://orbit.kiwi" target="_blank"> <img alt="orbit-components" src="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components.png" srcset="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components@2x.png 2x"
39 lines (32 loc) • 1.21 kB
JavaScript
// @flow
import React from "react";
import styled from "styled-components";
import defaultTokens from "../defaultTokens";
const StyledAsterisk = styled.span`
font-weight: ${({ theme }) => theme.orbit.fontWeightBold};
color: ${({ theme, filled }) =>
!filled ? theme.orbit.colorTextError : theme.orbit.colorFormLabelFilled};
font-size: ${({ theme }) => theme.orbit.fontSizeFormLabel};
vertical-align: top;
`;
StyledAsterisk.defaultProps = {
theme: defaultTokens,
};
const FormLabel = styled(({ className, children, required, filled, dataTest }) => (
<span className={className} data-test={dataTest}>
{required && <StyledAsterisk filled={filled}>* </StyledAsterisk>}
<span>{children}</span>
</span>
))`
display: block;
font-family: ${({ theme }) => theme.orbit.fontFamily};
font-size: ${({ theme }) => theme.orbit.fontSizeFormLabel};
color: ${({ theme, filled, disabled }) =>
!filled || disabled ? theme.orbit.colorFormLabel : theme.orbit.colorFormLabelFilled};
line-height: ${({ theme }) => theme.orbit.lineHeightText};
margin-bottom: ${({ theme }) => theme.orbit.spaceXXSmall};
`;
FormLabel.defaultProps = {
theme: defaultTokens,
};
export default FormLabel;