ghost-portal/packages/react-components/src/Flag.tsx
Jaco 2bf56dbf11
Adjust styled injection (final round) (#8814)
* Adjust styled injection (final round)

* Fix (some) build issues

* Fix (some more) build errors

* ... it builds (... ship it!)
2023-01-15 19:53:55 +02:00

69 lines
1.4 KiB
TypeScript

// Copyright 2017-2023 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { FlagColor } from './types';
import React from 'react';
import styled from 'styled-components';
import Tag from './Tag';
interface FlagProps {
className?: string;
color: FlagColor;
label: React.ReactNode;
}
function Flag ({ className = '', color, label }: FlagProps): React.ReactElement<FlagProps> {
return (
<StyledTag
className={`${className} ${color === 'theme' ? ' highlight--color-bg highlight--bg' : ''}` }
color={color}
label={label}
size='tiny'
/>
);
}
const StyledTag = styled(Tag)`
border-radius: 0 0.25rem 0.25rem 0;
padding: 0.5833em 1.25em 0.5833em 1.5em;
font-size: var(--font-size-tiny);
line-height: 1;
color: #fff !important;
&.darkTheme {
:after {
background-color: var(--bg-tabs);
}
}
&:after {
background-color: #fff;
border-radius: 500rem;
content: '';
left: -0.25em;
margin-top: -0.25em;
position: absolute;
width: 0.5em;
height: 0.5em;
top: 50%;
}
&:before {
border-radius: 0.2rem 0 0.1rem 0;
background-color: inherit;
background-image: none;
content: '';
right: 100%;
width: 1.5em;
height: 1.5em;
position: absolute;
transform: translateY(-50%) translateX(50%) rotate(-45deg);
top: 50%;
transition: none;
}
`;
export default React.memo(Flag);