slate/components/core/TabGroup.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-09-03 02:38:29 +03:00
import * as React from "react";
import * as Constants from "~/common/constants";
import { css } from "@emotion/react";
const STYLES_TAB_GROUP = css`
margin: 36px 0px 24px 0px;
padding: 0 0 0 2px;
display: flex;
align-items: flex-start;
flex-direction: row;
box-sizing: border-box;
font-family: ${Constants.font.text};
width: 100%;
`;
const STYLES_TAB = css`
padding: 8px 8px 8px 0px;
margin-right: 24px;
display: inline-block;
font-size: ${Constants.typescale.lvl1};
2020-09-04 07:16:19 +03:00
font-family: ${Constants.font.medium};
2020-09-03 02:38:29 +03:00
user-select: none;
@media (max-width: ${Constants.sizes.mobile}px) {
margin-right: 12px;
}
`;
export class TabGroup extends React.Component {
render() {
return (
2020-09-08 00:45:58 +03:00
<div css={STYLES_TAB_GROUP} style={this.props.style}>
2020-09-03 02:38:29 +03:00
{this.props.tabs.map((tab, i) => (
<div
css={STYLES_TAB}
key={tab}
style={{
2020-09-04 07:42:50 +03:00
color:
2020-09-08 00:45:58 +03:00
this.props.disabled || this.props.value === i
2020-09-04 07:42:50 +03:00
? Constants.system.black
: "rgba(0,0,0,0.25)",
2020-09-08 00:45:58 +03:00
cursor: this.props.disabled ? "auto" : "pointer",
...this.props.itemStyle,
2020-09-03 02:38:29 +03:00
}}
2020-09-08 00:45:58 +03:00
onClick={
this.props.disabled ? () => {} : () => this.props.onChange(i)
}
2020-09-03 02:38:29 +03:00
>
{tab}
</div>
))}
</div>
);
}
}