1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

make better flow cell text

This commit is contained in:
Fedor Katurov 2025-02-07 01:11:12 +07:00
parent 7924c2bdd9
commit 69c61acc41
7 changed files with 60 additions and 30 deletions

View file

@ -23,6 +23,7 @@ interface Props {
const FlowCellMenu: FC<Props> = ({ const FlowCellMenu: FC<Props> = ({
onClose, onClose,
currentView,
hasDescription, hasDescription,
toggleViewDescription, toggleViewDescription,
descriptionEnabled, descriptionEnabled,
@ -59,7 +60,7 @@ const FlowCellMenu: FC<Props> = ({
/> />
</div> </div>
{hasDescription && ( {hasDescription && currentView !== 'single' && (
<Group <Group
className={styles.description} className={styles.description}
horizontal horizontal

View file

@ -1,6 +1,7 @@
import { FC, ReactElement } from 'react'; import { FC, ReactElement } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { transparentize, darken, desaturate, getLuminance } from 'color2k';
import { Markdown } from '~/components/common/Markdown'; import { Markdown } from '~/components/common/Markdown';
import { formatText } from '~/utils/dom'; import { formatText } from '~/utils/dom';
@ -11,13 +12,29 @@ import styles from './styles.module.scss';
interface Props extends DivProps { interface Props extends DivProps {
children: string; children: string;
heading: string | ReactElement; heading: string | ReactElement;
color?: string;
} }
const FlowCellText: FC<Props> = ({ children, heading, ...rest }) => ( const FlowCellText: FC<Props> = ({ children, heading, color, ...rest }) => {
<div {...rest} className={classNames(styles.text, rest.className)}> const colorIsBright = !!color && getLuminance(color) > 0.4;
const textColor = colorIsBright
? desaturate(darken(color, 0.5), 0.1)
: undefined;
return (
<div
{...rest}
className={classNames(styles.text, rest.className)}
style={{
backgroundColor: color && transparentize(color, 0.5),
color: textColor,
}}
>
{heading && <div className={styles.heading}>{heading}</div>} {heading && <div className={styles.heading}>{heading}</div>}
<Markdown className={styles.description}>{formatText(children)}</Markdown> <Markdown className={styles.description}>{formatText(children)}</Markdown>
</div> </div>
); );
};
export { FlowCellText }; export { FlowCellText };

View file

@ -1,10 +1,16 @@
@import "src/styles/variables"; @import 'src/styles/variables';
.text { .text {
padding: $gap; @include blur;
padding: $gap / 2 $gap $gap $gap;
line-height: 1.3em; line-height: 1.3em;
} }
.heading { .heading {
margin-bottom: 0.4em; margin-bottom: 0.25em;
h4 {
// line-height: 1.1em;
}
} }

View file

@ -111,8 +111,9 @@ const FlowCell: FC<Props> = ({
<FlowCellText <FlowCellText
className={styles.text} className={styles.text}
heading={<h4 className={styles.title}>{title}</h4>} heading={<h4 className={styles.title}>{title}</h4>}
color={color}
> >
{text!} {text}
</FlowCellText> </FlowCellText>
)} )}

View file

@ -33,18 +33,20 @@
.text { .text {
position: absolute; position: absolute;
bottom: 5px;
left: 5px;
z-index: 1; z-index: 1;
overflow: hidden; overflow: hidden;
border-radius: $radius; border-radius: $radius;
max-height: calc(100% - 10px);
max-width: calc(100% - 10px);
box-sizing: border-box; box-sizing: border-box;
font: $font_16_regular; font: $font_14_medium;
line-height: 1.25em;
inset: 50% 0 0 0;
&.bright {
color: var(--content_bg_lightest);
}
@include tablet { @include tablet {
font: $font_14_regular; font: $font_12_medium;
left: 5px; left: 5px;
bottom: 5px; bottom: 5px;
} }
@ -54,14 +56,19 @@
opacity: 0.5; opacity: 0.5;
} }
.quadro &,
.horizontal & { .horizontal & {
max-width: calc(50% - 15px); inset: 0 calc(50% + $gap / 2) 0 0;
border-radius: $radius 0 0 $radius;
} }
.quadro &,
.vertical & { .vertical & {
max-height: calc(50% - 15px); inset: calc(50% + $gap / 2) 0 0 0;
border-radius: 0 0 $radius $radius;
}
.quadro & {
inset: calc(50% + $gap / 2) calc(50% + $gap / 2) 0 0;
border-radius: 0 $radius 0 $radius;
} }
} }
@ -76,11 +83,13 @@
.title { .title {
font: $font_cell_title; font: $font_cell_title;
line-height: 1.2em;
text-transform: uppercase; text-transform: uppercase;
word-break: break-word; word-break: break-word;
color: inherit;
@include tablet { @include tablet {
font: $font_18_semibold; font: $font_16_semibold;
} }
} }

View file

@ -63,10 +63,8 @@ $_brown: #23201f;
--content_bg_success: #{transparentize($_wisegreen, 0.7)}; --content_bg_success: #{transparentize($_wisegreen, 0.7)};
--content_bg_info: #{transparentize($_blue, 0.5)}; --content_bg_info: #{transparentize($_blue, 0.5)};
--content_bg_danger: #{transparentize($_red, 0.5)}; --content_bg_danger: #{transparentize($_red, 0.5)};
--content_bg_backdrop: url('/images/noise.png') #{transparentize( --content_bg_backdrop: url('/images/noise.png')
$_brown, #{transparentize($_brown, 0.3)};
0.3
)};
--content_bg_hero: url('/images/noise.png') #{transparentize($_brown, 0.6)}; --content_bg_hero: url('/images/noise.png') #{transparentize($_brown, 0.6)};
// white shades (move to --vars) // white shades (move to --vars)

View file

@ -85,10 +85,8 @@ $_ocean: #25b0bc;
--gray_90: #{transparentize(white, 0.95)}; --gray_90: #{transparentize(white, 0.95)};
// page background // page background
--page-background: 50% 50% / cover no-repeat url('/images/horizon_bg.svg') #{darken( --page-background: 50% 50% / cover no-repeat url('/images/horizon_bg.svg')
$_cold, #{darken($_cold, 4%)} fixed;
4%
)} fixed;
--page-background-top: linear-gradient( --page-background-top: linear-gradient(
#{$_accent} -150%, #{$_accent} -150%,
#{transparentize($_ocean, 0.99)} 100px, #{transparentize($_ocean, 0.99)} 100px,