@twind/line-clamp
Version:
A twind plugin that provides utilities for visually truncating text after a fixed number of lines.
8 lines (7 loc) • 1.25 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../index.ts"],
"sourcesContent": ["import type { Context, CSSRules, ThemeSection, Directive } from 'twind'\nimport { directive } from 'twind'\n\ndeclare module 'twind' {\n interface Theme {\n lineClamp?: ThemeSection<string | number>\n }\n}\n\nexport interface LineClamp {\n (lines: 'none' | number | string): Directive<CSSRules>\n (parts: string[], context: Context): CSSRules\n}\n\nconst lineClamp$ = (lines: string, { theme }: Context): CSSRules =>\n lines === 'none'\n ? {\n WebkitLineClamp: 'unset',\n }\n : {\n overflow: 'hidden',\n display: '-webkit-box',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: `${theme('lineClamp', lines, lines)}`,\n }\n\nexport const lineClamp = ((\n lines: number | 'none' | string[],\n context: Context,\n): Directive<CSSRules> | CSSRules =>\n Array.isArray(lines)\n ? lineClamp$(lines[0], context)\n : directive(lineClamp$, `${lines}`)) as LineClamp\n"],
"mappings": "AACA,kCAaA,GAAM,GAAa,CAAC,EAAe,CAAE,WACnC,IAAU,OACN,CACE,gBAAiB,SAEnB,CACE,SAAU,SACV,QAAS,cACT,gBAAiB,WACjB,gBAAiB,GAAG,EAAM,YAAa,EAAO,MAGzC,EAAa,CACxB,EACA,IAEA,MAAM,QAAQ,GACV,EAAW,EAAM,GAAI,GACrB,EAAU,EAAY,GAAG",
"names": []
}