@braineet/ui
Version:
Braineet design system
122 lines • 5.05 kB
JavaScript
/* eslint-disable no-nested-ternary */
import { SelectPopover, Select } from 'ariakit/select';
import styled, { css } from 'styled-components';
import { variant } from 'styled-system';
import { borderRadius, fluid } from '../../utils';
import Box from '../box';
import Icon from '../icon';
import Text from '../text';
var selectSize = function selectSize(p) {
return variant({
prop: 'size',
variants: {
sm: {
height: '32px',
fontSize: p.theme.typo.text.sm.fontSize
},
md: {
height: '40px',
fontSize: p.theme.typo.text.md.fontSize
}
}
});
};
var selectedSize = function selectedSize(p) {
return variant({
prop: 'size',
variants: {
sm: {
fontSize: p.theme.typo.text.sm.fontSize
},
md: {
fontSize: p.theme.typo.text.md.fontSize
}
}
});
};
var Default = css(["background-color:", ";padding:0 ", " 0 ", ";color:", ";&:not([disabled]):hover{background-color:", ";}"], function (props) {
return props.theme.colors.background.light.grey;
}, fluid(36), fluid(8), function (props) {
return props.theme.utils.lighten('black', 0.6);
}, function (p) {
return p.theme.utils.lighten('black', 0.1);
});
var Invalid = css(["&[data-invalid]{border:2px solid ", ";padding:0 ", " 0 ", ";background-color:", ";}"], function (p) {
return p.theme.colors.error;
}, fluid(75), fluid(16), function (p) {
return p.theme.colors.white;
});
var Focused = css(["&:focus{border:2px solid ", ";}&:focus:not(:disabled),&:focus:not(:focus-visible){background-color:", ";outline:none;}"], function (p) {
return p.theme.colors.brand;
}, function (props) {
return props.theme.colors.white;
});
var Disabled = css(["&:disabled{opacity:0.24;cursor:not-allowed;}"]);
var Filled = css(["&[data-filled]{color:", ";background-color:", ";}"], function (p) {
return p.theme.colors.black;
}, function (p) {
return p.theme.colors.white;
});
export var StyledSelect = styled(Select).withConfig({
displayName: "styles__StyledSelect",
componentId: "sc-1c3zjd8-0"
})(["display:block;width:100%;outline:none;box-sizing:border-box;border-radius:", ";position:relative;display:", ";text-align:left;box-sizing:border-box;line-height:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;border:2px solid ", ";cursor:pointer;", " &:read-only{cursor:default;}", " ", " ", " ", " ", " ", " ", ""], function (props) {
return props.theme.borderRadius.md;
}, function (props) {
return !props.disableSearch ? 'block' : 'none';
}, function (p) {
return p.theme.utils.lighten('black', 0.1);
}, selectSize, borderRadius(8), Default, Filled, Focused, Invalid, Disabled, function (p) {
return p.$buttonStyle;
});
export var StyledSelected = styled(Box).withConfig({
displayName: "styles__StyledSelected",
componentId: "sc-1c3zjd8-1"
})(["display:flex;align-items:center;vertical-align:middle;height:100%;overflow:hidden;"]);
export var StyledSelectedText = styled(Text).withConfig({
displayName: "styles__StyledSelectedText",
componentId: "sc-1c3zjd8-2"
})(["color:", ";width:100%;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;", ""], function (p) {
return p.theme.utils.lighten('black', 0.8);
}, selectedSize);
export var SelectedIcon = styled(Icon).withConfig({
displayName: "styles__SelectedIcon",
componentId: "sc-1c3zjd8-3"
})(["margin-right:0.5rem;"]);
var getIconStyled = function getIconStyled(props) {
return {
right: props.height === 40 ? fluid(8) : fluid(4)
};
};
export var StyledIconSelect = styled(Icon).withConfig({
displayName: "styles__StyledIconSelect",
componentId: "sc-1c3zjd8-4"
})(["position:absolute;top:50%;transform:translate(0%,-50%);", ""], function (props) {
return getIconStyled(props);
});
export var SelectPopoverStyled = styled(SelectPopover).withConfig({
displayName: "styles__SelectPopoverStyled",
componentId: "sc-1c3zjd8-5"
})(["list-style:none;z-index:", ";max-height:min( var(--popover-available-height),", " );max-width:min( var(--popover-available-width),", " );overflow:auto;overscroll-behavior:contain;border:", ";background-color:", ";padding:", ";border-radius:8px;box-shadow:", ";outline:none !important;", ""], function (props) {
return props.$zIndex || (props.modal || props.portal ? props.theme.zIndex.overlay : props.theme.zIndex.dropdown);
}, function (p) {
return p.$maxHeightList || '320px';
}, function (p) {
return p.$maxWidthList || 'var(--popover-available-width)';
}, function (props) {
return props.isOpen && "2px solid " + props.theme.utils.lighten('black', 0.1);
}, function (props) {
return props.theme.colors.white;
}, function (p) {
return p.$padding || '0.5rem';
}, function (props) {
return props.theme.elevations[4];
}, function (p) {
return p.$popoverStyles;
});
export var Img = styled.div.withConfig({
displayName: "styles__Img",
componentId: "sc-1c3zjd8-6"
})(["width:24px;height:24px;display:block;background:url('", "') no-repeat;background-size:24px 24px;margin-right:0.5em;"], function (props) {
return props.path;
});