Skip to content

Commit

Permalink
feat(typography): support annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Sep 15, 2023
1 parent 14907f3 commit ee9f49e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/typography/css/annotation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { getNonCjkBlockCss } from "./nonCjkBlock";
import { getVariables } from "./variables";

export const generateAnnotationCss = (selectorName: string) => {
return `
.${selectorName}--annotation p {
margin-block-start: 0;
margin-block-end: 0;
line-height: 2.25;
text-indent: ${getVariables.textIndentLength};
}
.${selectorName}--annotation em {
-webkit-text-emphasis: filled circle;
-webkit-text-emphasis-position: under;
text-emphasis: filled circle;
text-emphasis-position: under right;
font-weight: ${getVariables.fontWeightNormal};
}
${getNonCjkBlockCss(`${selectorName}--annotation em`, {
"-webkit-text-emphasis": "none",
"text-emphasis": "none",
})}
.${selectorName}--annotation .${selectorName}-meta {
margin-block-start: calc(${getVariables.stdBlockUnit} * 0.5);
margin-block-end: ${getVariables.stdBlockUnit};
}
`;
};
7 changes: 7 additions & 0 deletions src/typography/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getPreflights } from "./preflights";
import { generateAncientCss } from "./css/ancient";
import type { TypographyCompatibilityOptions } from "./types/compatibilityOptions";
import { generateDefaultVariables } from "./preflights/variables";
import { generateAnnotationCss } from "./css/annotation";

/**
* @public
Expand Down Expand Up @@ -210,6 +211,12 @@ export function chineseTypography(options?: TypographyOptions): Preset<Theme> {
return generateAncientCss(selectorName);
},
},
{
layer: "typography",
getCSS: () => {
return generateAnnotationCss(selectorName);
},
},
{
layer: "typography",
getCSS: () => {
Expand Down

0 comments on commit ee9f49e

Please sign in to comment.