mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-22 21:50:43 +03:00
Fix links chip design (#5963)
Fix https://github.com/twentyhq/twenty/issues/5938 and https://github.com/twentyhq/twenty/issues/5655 - Make sure chip count is displayed - Fix padding - Fix background colors, border - Add hover and active states --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
parent
732653034e
commit
9a4a2e4ca9
@ -59,7 +59,7 @@ export const LinksDisplay = ({ value, isFocused }: LinksDisplayProps) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return isFocused ? (
|
return isFocused ? (
|
||||||
<ExpandableList isChipCountDisplayed={isFocused}>
|
<ExpandableList isChipCountDisplayed>
|
||||||
{links.map(({ url, label, type }, index) =>
|
{links.map(({ url, label, type }, index) =>
|
||||||
type === LinkType.LinkedIn || type === LinkType.Twitter ? (
|
type === LinkType.LinkedIn || type === LinkType.Twitter ? (
|
||||||
<SocialLink key={index} href={url} type={type} label={label} />
|
<SocialLink key={index} href={url} type={type} label={label} />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { MouseEvent } from 'react';
|
import { MouseEvent, useContext } from 'react';
|
||||||
import { styled } from '@linaria/react';
|
import { styled } from '@linaria/react';
|
||||||
import { isNonEmptyString } from '@sniptt/guards';
|
import { isNonEmptyString } from '@sniptt/guards';
|
||||||
import { FONT_COMMON, THEME_COMMON } from 'twenty-ui';
|
import { FONT_COMMON, THEME_COMMON, ThemeContext } from 'twenty-ui';
|
||||||
|
|
||||||
type RoundedLinkProps = {
|
type RoundedLinkProps = {
|
||||||
href: string;
|
href: string;
|
||||||
@ -11,17 +11,23 @@ type RoundedLinkProps = {
|
|||||||
|
|
||||||
const fontSizeMd = FONT_COMMON.size.md;
|
const fontSizeMd = FONT_COMMON.size.md;
|
||||||
const spacing1 = THEME_COMMON.spacing(1);
|
const spacing1 = THEME_COMMON.spacing(1);
|
||||||
const spacing3 = THEME_COMMON.spacing(3);
|
const spacing2 = THEME_COMMON.spacing(2);
|
||||||
|
|
||||||
const spacingMultiplicator = THEME_COMMON.spacingMultiplicator;
|
const spacingMultiplicator = THEME_COMMON.spacingMultiplicator;
|
||||||
|
|
||||||
const StyledLink = styled.a`
|
const StyledLink = styled.a<{
|
||||||
|
color: string;
|
||||||
|
background: string;
|
||||||
|
backgroundHover: string;
|
||||||
|
backgroundActive: string;
|
||||||
|
border: string;
|
||||||
|
}>`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: var(--twentycrm-background-transparent-light);
|
background-color: ${({ background }) => background};
|
||||||
border: 1px solid var(--twentycrm-border-color-medium);
|
border: 1px solid ${({ border }) => border};
|
||||||
|
|
||||||
border-radius: 50px;
|
border-radius: 50px;
|
||||||
color: var(--twentycrm-font-color-primary);
|
color: ${({ color }) => color};
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@ -29,25 +35,39 @@ const StyledLink = styled.a`
|
|||||||
|
|
||||||
gap: ${spacing1};
|
gap: ${spacing1};
|
||||||
|
|
||||||
height: ${spacing3};
|
height: 10px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
max-width: calc(100% - ${spacingMultiplicator} * 2px);
|
max-width: calc(100% - ${spacingMultiplicator} * 2px);
|
||||||
|
|
||||||
max-width: 100%;
|
|
||||||
|
|
||||||
min-width: fit-content;
|
min-width: fit-content;
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: ${spacing1} ${spacing1};
|
padding: ${spacing1} ${spacing2};
|
||||||
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: ${({ backgroundHover }) => backgroundHover};
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background-color: ${({ backgroundActive }) => backgroundActive};
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const RoundedLink = ({ label, href, onClick }: RoundedLinkProps) => {
|
export const RoundedLink = ({ label, href, onClick }: RoundedLinkProps) => {
|
||||||
|
const { theme } = useContext(ThemeContext);
|
||||||
|
|
||||||
|
const background = theme.background.transparent.lighter;
|
||||||
|
const backgroundHover = theme.background.transparent.light;
|
||||||
|
const backgroundActive = theme.background.transparent.medium;
|
||||||
|
const border = theme.border.color.strong;
|
||||||
|
const color = theme.font.color.primary;
|
||||||
|
|
||||||
if (!isNonEmptyString(label)) {
|
if (!isNonEmptyString(label)) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
@ -64,6 +84,11 @@ export const RoundedLink = ({ label, href, onClick }: RoundedLinkProps) => {
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
color={color}
|
||||||
|
background={background}
|
||||||
|
backgroundHover={backgroundHover}
|
||||||
|
backgroundActive={backgroundActive}
|
||||||
|
border={border}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</StyledLink>
|
</StyledLink>
|
||||||
|
Loading…
Reference in New Issue
Block a user