Skip to content

Commit

Permalink
feat: Add order and opacity shorthand styles (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdow committed Mar 5, 2024
1 parent c3679da commit c5e5d2c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
30 changes: 30 additions & 0 deletions packages/template-tachyons/src/Css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,10 @@ class CssBuilder<T extends Properties> {
flexWrap(value: Properties["flexWrap"]) {
return this.add("flexWrap", value);
}
/** Sets `order: value`. */
order(value: Properties["order"]) {
return this.add("order", value);
}

// float
/** Sets `float: "left"`. */
Expand Down Expand Up @@ -1241,6 +1245,32 @@ class CssBuilder<T extends Properties> {
return this.add("objectFit", value);
}

// opacity
/** Sets `opacity: "0"`. */
get o0() {
return this.add("opacity", "0");
}
/** Sets `opacity: "0.25"`. */
get o25() {
return this.add("opacity", "0.25");
}
/** Sets `opacity: "0.5"`. */
get o50() {
return this.add("opacity", "0.5");
}
/** Sets `opacity: "0.75"`. */
get o75() {
return this.add("opacity", "0.75");
}
/** Sets `opacity: "1"`. */
get o100() {
return this.add("opacity", "1");
}
/** Sets `opacity: value`. */
o(value: Properties["opacity"]) {
return this.add("opacity", value);
}

// outline
/** Sets `outline: "1px solid"`. */
get outline1() {
Expand Down
30 changes: 30 additions & 0 deletions packages/testing-tachyons/src/Css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ class CssBuilder<T extends Properties> {
flexWrap(value: Properties["flexWrap"]) {
return this.add("flexWrap", value);
}
/** Sets `order: value`. */
order(value: Properties["order"]) {
return this.add("order", value);
}

// float
/** Sets `float: "left"`. */
Expand Down Expand Up @@ -1141,6 +1145,32 @@ class CssBuilder<T extends Properties> {
return this.add("objectFit", value);
}

// opacity
/** Sets `opacity: "0"`. */
get o0() {
return this.add("opacity", "0");
}
/** Sets `opacity: "0.25"`. */
get o25() {
return this.add("opacity", "0.25");
}
/** Sets `opacity: "0.5"`. */
get o50() {
return this.add("opacity", "0.5");
}
/** Sets `opacity: "0.75"`. */
get o75() {
return this.add("opacity", "0.75");
}
/** Sets `opacity: "1"`. */
get o100() {
return this.add("opacity", "1");
}
/** Sets `opacity: value`. */
o(value: Properties["opacity"]) {
return this.add("opacity", value);
}

// outline
/** Sets `outline: "1px solid"`. */
get outline1() {
Expand Down
4 changes: 3 additions & 1 deletion packages/truss/src/sections/tachyons/flexbox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CreateMethodsFn } from "src/config";
import { newMethodsForProp } from "src/methods";
import { newMethodsForProp, newParamMethod } from "src/methods";

// We originally used the tachyons mappings:
// https://github.com/tachyons-css/tachyons/blob/master/src/_flexbox.css#L17
Expand Down Expand Up @@ -171,4 +171,6 @@ export const flexbox: CreateMethodsFn = () => [
},
"flexWrap",
),

newParamMethod("order", "order"),
];
2 changes: 2 additions & 0 deletions packages/truss/src/sections/tachyons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { width } from "src/sections/tachyons/widths";
import { wordBreak } from "src/sections/tachyons/wordBreak";
import { zIndex } from "src/sections/tachyons/zIndex";
import { container } from "src/sections/tachyons/container";
import { opacity } from "src/sections/tachyons/opacity";

export const defaultSections = {
border,
Expand All @@ -51,6 +52,7 @@ export const defaultSections = {
height,
lineClamp,
objectFit,
opacity,
outline,
overflow,
position,
Expand Down
16 changes: 16 additions & 0 deletions packages/truss/src/sections/tachyons/opacity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CreateMethodsFn } from "src/config";
import { newMethodsForProp } from "src/methods";

export const opacity: CreateMethodsFn = () => [
...newMethodsForProp(
"opacity",
{
o0: "0",
o25: "0.25",
o50: "0.5",
o75: "0.75",
o100: "1",
},
"o",
),
];

0 comments on commit c5e5d2c

Please sign in to comment.