mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-09-13 14:22:25 +03:00

* add buttons to codeblocks * add functionality * Document functions * Improve accessibility * Remove pointless DefaultReset * implement some requested changes * fix content shift when expanding or collapsing --------- Co-authored-by: Ajay Bura <32841439+ajbura@users.noreply.github.com>
246 lines
4.9 KiB
TypeScript
246 lines
4.9 KiB
TypeScript
import { style } from '@vanilla-extract/css';
|
|
import { recipe } from '@vanilla-extract/recipes';
|
|
import { color, config, DefaultReset, toRem } from 'folds';
|
|
|
|
export const MarginSpaced = style({
|
|
marginBottom: config.space.S200,
|
|
marginTop: config.space.S200,
|
|
selectors: {
|
|
'&:first-child': {
|
|
marginTop: 0,
|
|
},
|
|
'&:last-child': {
|
|
marginBottom: 0,
|
|
},
|
|
},
|
|
});
|
|
|
|
export const Paragraph = style([DefaultReset]);
|
|
|
|
export const Heading = style([
|
|
DefaultReset,
|
|
MarginSpaced,
|
|
{
|
|
marginTop: config.space.S400,
|
|
selectors: {
|
|
'&:first-child': {
|
|
marginTop: 0,
|
|
},
|
|
},
|
|
},
|
|
]);
|
|
|
|
export const BlockQuote = style([
|
|
DefaultReset,
|
|
MarginSpaced,
|
|
{
|
|
paddingLeft: config.space.S200,
|
|
borderLeft: `${config.borderWidth.B700} solid ${color.SurfaceVariant.ContainerLine}`,
|
|
fontStyle: 'italic',
|
|
},
|
|
]);
|
|
|
|
const BaseCode = style({
|
|
fontFamily: 'monospace',
|
|
color: color.Secondary.OnContainer,
|
|
background: color.Secondary.Container,
|
|
border: `${config.borderWidth.B300} solid ${color.Secondary.ContainerLine}`,
|
|
borderRadius: config.radii.R300,
|
|
});
|
|
|
|
export const Code = style([
|
|
DefaultReset,
|
|
BaseCode,
|
|
{
|
|
padding: `0 ${config.space.S100}`,
|
|
},
|
|
]);
|
|
|
|
export const Spoiler = recipe({
|
|
base: [
|
|
DefaultReset,
|
|
{
|
|
padding: `0 ${config.space.S100}`,
|
|
backgroundColor: color.SurfaceVariant.ContainerActive,
|
|
borderRadius: config.radii.R300,
|
|
selectors: {
|
|
'&[aria-pressed=true]': {
|
|
color: 'transparent',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
variants: {
|
|
active: {
|
|
true: {
|
|
color: 'transparent',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
export const CodeBlock = style([
|
|
DefaultReset,
|
|
BaseCode,
|
|
MarginSpaced,
|
|
{
|
|
fontStyle: 'normal',
|
|
position: 'relative',
|
|
},
|
|
]);
|
|
export const CodeBlockInternal = recipe({
|
|
base: {
|
|
padding: `${config.space.S200} ${config.space.S200} 0`,
|
|
minWidth: toRem(100),
|
|
},
|
|
variants: {
|
|
collapsed: {
|
|
true: {
|
|
maxHeight: `calc(${config.lineHeight.T400} * 9.6)`,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
export const CodeBlockControls = style({
|
|
position: 'absolute',
|
|
top: config.space.S200,
|
|
right: config.space.S200,
|
|
visibility: 'hidden',
|
|
selectors: {
|
|
[`${CodeBlock}:hover &`]: {
|
|
visibility: 'visible',
|
|
},
|
|
[`${CodeBlock}:focus-within &`]: {
|
|
visibility: 'visible',
|
|
},
|
|
},
|
|
});
|
|
|
|
export const List = style([
|
|
DefaultReset,
|
|
MarginSpaced,
|
|
{
|
|
padding: `0 ${config.space.S100}`,
|
|
paddingLeft: config.space.S600,
|
|
},
|
|
]);
|
|
|
|
export const Img = style([
|
|
DefaultReset,
|
|
MarginSpaced,
|
|
{
|
|
maxWidth: toRem(296),
|
|
borderRadius: config.radii.R300,
|
|
},
|
|
]);
|
|
|
|
export const InlineChromiumBugfix = style({
|
|
fontSize: 0,
|
|
lineHeight: 0,
|
|
});
|
|
|
|
export const Mention = recipe({
|
|
base: [
|
|
DefaultReset,
|
|
{
|
|
backgroundColor: color.SurfaceVariant.Container,
|
|
color: color.SurfaceVariant.OnContainer,
|
|
boxShadow: `0 0 0 ${config.borderWidth.B300} ${color.SurfaceVariant.ContainerLine}`,
|
|
padding: `0 ${toRem(2)}`,
|
|
borderRadius: config.radii.R300,
|
|
fontWeight: config.fontWeight.W500,
|
|
},
|
|
],
|
|
variants: {
|
|
highlight: {
|
|
true: {
|
|
backgroundColor: color.Success.Container,
|
|
color: color.Success.OnContainer,
|
|
boxShadow: `0 0 0 ${config.borderWidth.B300} ${color.Success.ContainerLine}`,
|
|
},
|
|
},
|
|
focus: {
|
|
true: {
|
|
boxShadow: `0 0 0 ${config.borderWidth.B300} ${color.SurfaceVariant.OnContainer}`,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
export const Command = recipe({
|
|
base: [
|
|
DefaultReset,
|
|
{
|
|
padding: `0 ${toRem(2)}`,
|
|
borderRadius: config.radii.R300,
|
|
fontWeight: config.fontWeight.W500,
|
|
},
|
|
],
|
|
variants: {
|
|
focus: {
|
|
true: {
|
|
boxShadow: `0 0 0 ${config.borderWidth.B300} ${color.Warning.OnContainer}`,
|
|
},
|
|
},
|
|
active: {
|
|
true: {
|
|
backgroundColor: color.Warning.Container,
|
|
color: color.Warning.OnContainer,
|
|
boxShadow: `0 0 0 ${config.borderWidth.B300} ${color.Warning.ContainerLine}`,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
export const EmoticonBase = style([
|
|
DefaultReset,
|
|
{
|
|
display: 'inline-block',
|
|
padding: '0.05rem',
|
|
height: '1em',
|
|
verticalAlign: 'middle',
|
|
},
|
|
]);
|
|
|
|
export const Emoticon = recipe({
|
|
base: [
|
|
DefaultReset,
|
|
{
|
|
display: 'inline-flex',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
|
|
height: '1em',
|
|
minWidth: '1em',
|
|
fontSize: '1.33em',
|
|
lineHeight: '1em',
|
|
verticalAlign: 'middle',
|
|
position: 'relative',
|
|
top: '-0.35em',
|
|
borderRadius: config.radii.R300,
|
|
},
|
|
],
|
|
variants: {
|
|
focus: {
|
|
true: {
|
|
boxShadow: `0 0 0 ${config.borderWidth.B300} ${color.SurfaceVariant.OnContainer}`,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
export const EmoticonImg = style([
|
|
DefaultReset,
|
|
{
|
|
height: '1em',
|
|
cursor: 'default',
|
|
},
|
|
]);
|
|
|
|
export const highlightText = style([
|
|
DefaultReset,
|
|
{
|
|
backgroundColor: 'yellow',
|
|
color: 'black',
|
|
},
|
|
]);
|