Skip to content

Commit

Permalink
Add lh/lhPx as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenh committed Jun 18, 2024
1 parent 5864cb3 commit a5618c4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
20 changes: 12 additions & 8 deletions packages/template-tachyons/src/Css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2200,14 +2200,6 @@ class CssBuilder<T extends Properties> {
get tiny() {
return this.add("fontWeight", 400).add("fontSize", "10px").add("lineHeight", "14px");
}
/** Sets `fontSize: value`. */
fs(value: Properties["fontSize"]) {
return this.add("fontSize", value);
}
/** Sets `fontSize: px`. */
fsPx(px: number) {
return this.fs(`${px}px`);
}

// typography
/** Sets `maxWidth: "30em"`. */
Expand All @@ -2234,10 +2226,22 @@ class CssBuilder<T extends Properties> {
get truncate() {
return this.add("whiteSpace", "nowrap").add("overflow", "hidden").add("textOverflow", "ellipsis");
}
/** Sets `fontSize: value`. */
fs(value: Properties["fontSize"]) {
return this.add("fontSize", value);
}
/** Sets `fontSize: px`. */
fsPx(px: number) {
return this.fs(`${px}px`);
}
/** Sets `lineHeight: value`. */
lh(value: Properties["lineHeight"]) {
return this.add("lineHeight", value);
}
/** Sets `lineHeight: px`. */
lhPx(px: number) {
return this.lh(`${px}px`);
}

// userSelect
/** Sets `userSelect: "none"`. */
Expand Down
20 changes: 12 additions & 8 deletions packages/testing-tachyons/src/Css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1906,14 +1906,6 @@ class CssBuilder<T extends Properties> {
get f10() {
return this.add("fontSize", "10px").add("fontWeight", 500);
}
/** Sets `fontSize: value`. */
fs(value: Properties["fontSize"]) {
return this.add("fontSize", value);
}
/** Sets `fontSize: px`. */
fsPx(px: number) {
return this.fs(`${px}px`);
}

// typography
/** Sets `maxWidth: "30em"`. */
Expand All @@ -1940,10 +1932,22 @@ class CssBuilder<T extends Properties> {
get truncate() {
return this.add("whiteSpace", "nowrap").add("overflow", "hidden").add("textOverflow", "ellipsis");
}
/** Sets `fontSize: value`. */
fs(value: Properties["fontSize"]) {
return this.add("fontSize", value);
}
/** Sets `fontSize: px`. */
fsPx(px: number) {
return this.fs(`${px}px`);
}
/** Sets `lineHeight: value`. */
lh(value: Properties["lineHeight"]) {
return this.add("lineHeight", value);
}
/** Sets `lineHeight: px`. */
lhPx(px: number) {
return this.lh(`${px}px`);
}

// userSelect
/** Sets `userSelect: "none"`. */
Expand Down
3 changes: 0 additions & 3 deletions packages/truss/src/sections/tachyons/typeScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ export const typeScale: CreateMethodsFn = ({ fonts }) => [
}
return newMethod(abbr, defs);
}),
// Include `fs(...)` & `fsPx(...)` for one-off font-sizes. We technically also have
// `fs0` and `fs1` for `flexShrink`, but this seems fine.
...newMethodsForProp("fontSize", {}, "fs", true),
];
7 changes: 5 additions & 2 deletions packages/truss/src/sections/tachyons/typography.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newMethod, newParamMethod } from "src/methods";
import { newMethod, newMethodsForProp, newParamMethod } from "src/methods";
import { CreateMethodsFn } from "src/config";

// See typeScale for the FontConfig.fonts handling
Expand All @@ -18,5 +18,8 @@ export const typography: CreateMethodsFn = () => [
overflow: "hidden",
textOverflow: "ellipsis",
}),
newParamMethod("lh", "lineHeight"),
// Include `fs(...)` & `fsPx(...)` for one-off font-sizes. We technically also have
// `fs0` and `fs1` for `flexShrink`, but this seems fine.
...newMethodsForProp("fontSize", {}, "fs", true),
...newMethodsForProp("lineHeight", {}, "lh", true),
];

0 comments on commit a5618c4

Please sign in to comment.