Skip to content

Commit 38e9d93

Browse files
committed
feat: border shorthand
1 parent 4443017 commit 38e9d93

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/compiler/declarations.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ export function parseDeclaration(
758758
parseOptions,
759759
),
760760
"border-style": parseBorderStyle(declaration.value.style, parseOptions),
761+
"border-color": parseColor(declaration.value.color, parseOptions),
761762
});
762763
return;
763764
case "border-top":
@@ -3144,7 +3145,12 @@ function kebabCase(str: string) {
31443145
);
31453146
}
31463147

3147-
const runtimeShorthands = new Set(["animation", "text-shadow", "transform"]);
3148+
const runtimeShorthands = new Set([
3149+
"animation",
3150+
"text-shadow",
3151+
"transform",
3152+
"border",
3153+
]);
31483154

31493155
const namedColors = new Set([
31503156
"aliceblue",

src/runtime/native/styles/border.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { shorthandHandler } from "./shorthand";
2+
3+
const width = ["borderWidth", "number"] as const;
4+
const style = ["borderStyle", "string"] as const;
5+
const color = ["borderColor", "color", "color"] as const;
6+
7+
export const border = shorthandHandler(
8+
[[width, style, color], [style, color], [width, style], [style]],
9+
[],
10+
);

src/runtime/native/styles/resolve.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
import type { RenderGuard } from "../conditions/guards";
88
import { type Getter, type VariableContextValue } from "../reactivity";
99
import { animation } from "./animation";
10+
import { border } from "./border";
1011
import { calc } from "./calc";
1112
import { transformKeys } from "./defaults";
1213
import {
@@ -34,6 +35,12 @@ export type StyleFunctionResolver = (
3435
options: ResolveValueOptions,
3536
) => any;
3637

38+
const shorthands: Record<`@${string}`, StyleFunctionResolver> = {
39+
"@textShadow": textShadow,
40+
"@transform": transform,
41+
"@border": border,
42+
};
43+
3744
const functions: Record<string, StyleFunctionResolver> = {
3845
calc,
3946
em,
@@ -46,9 +53,8 @@ const functions: Record<string, StyleFunctionResolver> = {
4653
fontScale,
4754
pixelSizeForLayoutSize,
4855
roundToNearestPixel,
49-
"@textShadow": textShadow,
50-
"@transform": transform,
5156
animationName: animation,
57+
...shorthands,
5258
};
5359

5460
export type ResolveValueOptions = {

0 commit comments

Comments
 (0)