UNPKG

@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"

35 lines (29 loc) 1.35 kB
import React from "react"; import styled from "styled-components"; import defaultTokens from "../defaultTokens"; const StyledAsterisk = styled.span.withConfig({ displayName: "FormLabel__StyledAsterisk" })(["font-weight:", ";color:", ";font-size:", ";vertical-align:top;"], ({ theme }) => theme.orbit.fontWeightBold, ({ theme, filled }) => !filled ? theme.orbit.colorTextError : theme.orbit.colorFormLabelFilled, ({ theme }) => theme.orbit.fontSizeFormLabel); StyledAsterisk.defaultProps = { theme: defaultTokens }; const FormLabel = styled(({ className, children, required, filled, dataTest }) => React.createElement( "span", { className: className, "data-test": dataTest }, required && React.createElement( StyledAsterisk, { filled: filled }, "* " ), React.createElement( "span", null, children ) )).withConfig({ displayName: "FormLabel" })(["display:block;font-family:", ";font-size:", ";color:", ";line-height:", ";margin-bottom:", ";"], ({ theme }) => theme.orbit.fontFamily, ({ theme }) => theme.orbit.fontSizeFormLabel, ({ theme, filled, disabled }) => !filled || disabled ? theme.orbit.colorFormLabel : theme.orbit.colorFormLabelFilled, ({ theme }) => theme.orbit.lineHeightText, ({ theme }) => theme.orbit.spaceXXSmall); FormLabel.defaultProps = { theme: defaultTokens }; export default FormLabel;