This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/app/components/Sidebar/components/TeamButton.js

89 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-09-04 00:27:12 +00:00
// @flow
2021-09-11 05:46:57 +00:00
import { observer } from "mobx-react";
import { ExpandedIcon } from "outline-icons";
import * as React from "react";
import styled from "styled-components";
import Flex from "components/Flex";
import TeamLogo from "components/TeamLogo";
2017-09-04 00:27:12 +00:00
type Props = {|
teamName: string,
subheading: React.Node,
2018-05-12 18:09:59 +00:00
showDisclosure?: boolean,
onClick: (event: SyntheticEvent<>) => void,
logoUrl: string,
|};
2017-09-04 00:27:12 +00:00
const TeamButton = React.forwardRef<Props, any>(
({ showDisclosure, teamName, subheading, logoUrl, ...rest }: Props, ref) => (
<Wrapper>
<Header justify="flex-start" align="center" ref={ref} {...rest}>
<TeamLogo
alt={`${teamName} logo`}
src={logoUrl}
width={38}
height={38}
/>
<Flex align="flex-start" column>
<TeamName showDisclosure>
{teamName} {showDisclosure && <Disclosure color="currentColor" />}
</TeamName>
<Subheading>{subheading}</Subheading>
</Flex>
</Header>
</Wrapper>
)
);
2017-09-04 00:27:12 +00:00
const Disclosure = styled(ExpandedIcon)`
position: absolute;
right: 0;
top: 0;
2018-05-06 21:01:28 +00:00
`;
const Subheading = styled.div`
padding-left: 10px;
font-size: 11px;
text-transform: uppercase;
font-weight: 500;
white-space: nowrap;
color: ${(props) => props.theme.sidebarText};
2017-09-04 06:03:49 +00:00
`;
2017-09-04 15:32:31 +00:00
const TeamName = styled.div`
position: relative;
padding-left: 10px;
padding-right: 24px;
font-weight: 600;
color: ${(props) => props.theme.text};
white-space: nowrap;
2017-09-04 00:27:12 +00:00
text-decoration: none;
font-size: 16px;
`;
const Wrapper = styled.div`
flex-shrink: 0;
overflow: hidden;
`;
const Header = styled.button`
display: flex;
align-items: center;
background: none;
line-height: inherit;
border: 0;
2021-04-19 04:52:54 +00:00
padding: 8px;
margin: 8px;
border-radius: 4px;
2017-09-04 06:03:49 +00:00
cursor: pointer;
2021-04-19 04:52:54 +00:00
width: calc(100% - 16px);
2017-09-04 06:03:49 +00:00
2017-09-04 15:32:31 +00:00
&:active,
2017-09-04 06:03:49 +00:00
&:hover {
transition: background 100ms ease-in-out;
2021-04-19 04:52:54 +00:00
background: ${(props) => props.theme.sidebarItemBackground};
2017-09-04 06:03:49 +00:00
}
2017-09-04 00:27:12 +00:00
`;
2021-09-11 05:46:57 +00:00
export default observer(TeamButton);