Skip to content

Commit 7c6ea0c

Browse files
Merge pull request #126 from gridaco/staging
March release #2
2 parents fbfcb06 + b566e2b commit 7c6ea0c

File tree

23 files changed

+527
-200
lines changed

23 files changed

+527
-200
lines changed

docs/css-blend-mode.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CSS - Blend mode
2+
3+
## Supported types
4+
5+
```
6+
normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity
7+
```
8+
9+
## Warning Lack of browser support on SVG element.
10+
11+
Applying `mix-blend-mode` to SVG element is limited in some browsers (safari & mobile browsers) See - https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode#browser_compatibility
12+
13+
### References
14+
15+
- [`mix-blend-mode`](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode)
16+
- [`background-blend-mode`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-blend-mode)

docs/css-multiple-background.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: "CSS How to handle multiple background fills"
3+
version: 0.1.0
4+
revision: 1
5+
---
6+
7+
# How to handle multiple background fills
8+
9+
## Definition of `"multiple background fills"`
10+
11+
- one or none active solid fill
12+
- one or more gradient fill above solid fill
13+
- one or more image fill
14+
15+
## Possible combinations
16+
17+
single solid fill
18+
19+
```css
20+
._1 {
21+
background: #fff;
22+
}
23+
._2 {
24+
background-color: #fff;
25+
}
26+
```
27+
28+
single solid fill with single gradient fill
29+
30+
```css
31+
._1 {
32+
background-color: #fff;
33+
background-image: linear-gradient(to bottom, #fff, #fff);
34+
}
35+
36+
._2 {
37+
background: #fff;
38+
background-image: linear-gradient(to bottom, #fff, #fff);
39+
}
40+
```
41+
42+
no solid fill with single gradient fill
43+
44+
```css
45+
._1 {
46+
background: linear-gradient(to bottom, #fff, #fff);
47+
}
48+
49+
._2 {
50+
background-image: linear-gradient(to bottom, #fff, #fff);
51+
}
52+
```
53+
54+
no solid fill with multiple gradient fill
55+
56+
```css
57+
._1 {
58+
background: linear-gradient(to bottom, #fff, #fff), linear-gradient(to bottom, #fff, #fff);
59+
}
60+
```

docs/css-text-gradient.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "CSS Gradient on text layer"
3+
version: 0.1.0
4+
revision: 1
5+
---
6+
7+
# CSS - Gradient on Text Layer
8+
9+
Applying a gradient to a text fill is quite different from simply giving a color to a text.
10+
Yet hooray CSS, it is much more simple than other platforms (flutter, android, ...)
11+
12+
**How to**
13+
14+
```css
15+
h1 {
16+
font-size: 72px;
17+
background: -webkit-linear-gradient(#eee, #333);
18+
-webkit-background-clip: text;
19+
-webkit-text-fill-color: transparent;
20+
}
21+
```
22+
23+
### References
24+
25+
- https://cssgradient.io/blog/css-gradient-text/
26+
- https://github.com/gridaco/designto-code/issues/84

docs/css-text-vertical-align.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "CSS Vertically align text content"
3+
version: 0.1.0
4+
revision: 1
5+
---
6+
7+
# Vertical align of text content
8+
9+
### References
10+
11+
- https://stackoverflow.com/questions/8865458/how-do-i-vertically-center-text-with-css

docs/figma-rotation.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,37 @@ revision: 1
1212

1313
> Figma rotation from [figma plugin docs](https://www.figma.com/plugin-docs/api/properties/nodes-rotation/#docsNav)
1414
15+
## [Note] The rotation value needs to be inverted on the client side.
16+
17+
to rotate something to the clockwise direction,
18+
19+
- figma: -n
20+
- client: +n (css)
21+
22+
the transform origin
23+
24+
- figma: not specified (always top left)
25+
- client: top left
26+
27+
**so the conversion from figma to css will be like below**
28+
29+
```
30+
# figma
31+
{
32+
x: 100,
33+
y: 100,
34+
rotation: 10,
35+
}
36+
37+
# css
38+
.rotate-n {
39+
top: 100;
40+
left: 100;
41+
transform: rotate(-10deg);
42+
transform-origin: top left;
43+
}
44+
```
45+
1546
## Transform?
1647

1748
While figma and other major design tools has both transform value, and explicit rotation value (which can be calculated from transform value), The intuitive way to represent a rotation value is by using a `Rotation` token. Overall all figma node properties, the only two property that has impact to final transform (based on css) is `scale` and `rotation`.

editor-packages/editor-canvas/canvas/canvas.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ export function Canvas({
320320
).map((h) => ({
321321
id: h.id,
322322
xywh: [h.absoluteX, h.absoluteY, h.width, h.height],
323+
rotation: h.rotation,
323324
}))
324325
: []
325326
}

editor-packages/editor-canvas/canvas/hud-surface.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface DisplayNodeMeta {
2222
absoluteY: number;
2323
width: number;
2424
height: number;
25+
rotation: number;
2526
}
2627

2728
export function HudSurface({
@@ -41,7 +42,7 @@ export function HudSurface({
4142
}: {
4243
offset: XY;
4344
zoom: number;
44-
highlights: { id: string; xywh: XYWH }[];
45+
highlights: { id: string; xywh: XYWH; rotation: number }[];
4546
labelDisplayNodes: DisplayNodeMeta[];
4647
selectedNodes: DisplayNodeMeta[];
4748
hide: boolean;
@@ -102,6 +103,7 @@ export function HudSurface({
102103
key={h.id}
103104
type="xywhr"
104105
xywh={h.xywh}
106+
rotation={h.rotation}
105107
zoom={zoom}
106108
width={2}
107109
/>
@@ -121,6 +123,7 @@ export function HudSurface({
121123
key={s.id}
122124
type="xywhr"
123125
xywh={xywh}
126+
rotation={s.rotation}
124127
zoom={zoom}
125128
width={1}
126129
/>

editor-packages/editor-canvas/overlay/hover-outline-hightlight.tsx

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,27 @@ import React from "react";
22
import { color_layer_highlight } from "../theme";
33
import { get_boinding_box } from "./math";
44
import { OulineSide } from "./outline-side";
5+
import { OverlayContainer } from "./overlay-container";
56
import type { OutlineProps } from "./types";
67

78
export function HoverOutlineHighlight({ width = 1, ...props }: OutlineProps) {
8-
const { xywh, zoom } = props;
9+
const { xywh, zoom, rotation } = props;
910
const bbox = get_boinding_box({ xywh, scale: zoom });
1011
const wh: [number, number] = [xywh[2], xywh[3]];
12+
const vprops = {
13+
wh: wh,
14+
zoom: props.zoom,
15+
width: width,
16+
box: bbox,
17+
color: color_layer_highlight,
18+
};
19+
1120
return (
12-
<>
13-
<OulineSide
14-
orientation="l"
15-
wh={wh}
16-
zoom={props.zoom}
17-
width={width}
18-
box={bbox}
19-
color={color_layer_highlight}
20-
/>
21-
<OulineSide
22-
orientation="t"
23-
wh={wh}
24-
zoom={props.zoom}
25-
width={width}
26-
box={bbox}
27-
color={color_layer_highlight}
28-
/>
29-
<OulineSide
30-
orientation="b"
31-
wh={wh}
32-
zoom={props.zoom}
33-
width={width}
34-
box={bbox}
35-
color={color_layer_highlight}
36-
/>
37-
<OulineSide
38-
orientation="r"
39-
wh={wh}
40-
zoom={props.zoom}
41-
width={width}
42-
box={bbox}
43-
color={color_layer_highlight}
44-
/>
45-
</>
21+
<OverlayContainer xywh={bbox} rotation={rotation}>
22+
<OulineSide orientation="l" {...vprops} />
23+
<OulineSide orientation="t" {...vprops} />
24+
<OulineSide orientation="b" {...vprops} />
25+
<OulineSide orientation="r" {...vprops} />
26+
</OverlayContainer>
4627
);
4728
}

editor-packages/editor-canvas/overlay/math.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export function get_boinding_box({
66
scale: number;
77
}): [number, number, number, number] {
88
const [x, y, w, h] = xywh;
9+
10+
// return the bounding box in [number, number, number, number] form with givven x, y, w, h, rotation and scale.
911
const [x1, y1, x2, y2] = [
1012
x * scale,
1113
y * scale,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from "react";
2+
3+
/**
4+
* @default - TODO: rotation not supported
5+
* @returns
6+
*/
7+
export function OverlayContainer({
8+
xywh,
9+
rotation = 0,
10+
children,
11+
}: {
12+
xywh: [number, number, number, number];
13+
rotation: number;
14+
children: React.ReactNode;
15+
}) {
16+
// const [x, y, w, h] = xywh;
17+
return (
18+
<div
19+
id="overlay-container"
20+
style={{
21+
pointerEvents: "none",
22+
willChange: "transform, opacity",
23+
// transformOrigin: `${x}px ${y}px`,
24+
// transform: `rotate(${-rotation}deg)`,
25+
}}
26+
>
27+
{children}
28+
</div>
29+
);
30+
}

editor-packages/editor-canvas/overlay/readonly-select-hightlight.tsx

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@ import type { OutlineProps } from "./types";
33
import { color_layer_readonly_highlight } from "../theme";
44
import { get_boinding_box } from "./math";
55
import { OulineSide } from "./outline-side";
6+
import { OverlayContainer } from "./overlay-container";
67

78
export function ReadonlySelectHightlight({
89
width = 1,
910
...props
1011
}: OutlineProps) {
11-
const { xywh, zoom } = props;
12+
const { xywh, zoom, rotation } = props;
1213
const bbox = get_boinding_box({ xywh, scale: zoom });
1314
const wh: [number, number] = [xywh[2], xywh[3]];
1415

1516
const handle_outline_width = width;
1617
const handle_size = 3;
1718
const dot_size = 4;
1819

20+
const sideprops = {
21+
wh: wh,
22+
zoom: props.zoom,
23+
width: width,
24+
box: bbox,
25+
color: color_layer_readonly_highlight,
26+
};
27+
1928
return (
20-
<div
21-
style={{
22-
pointerEvents: "none",
23-
}}
24-
>
29+
<OverlayContainer xywh={bbox} rotation={rotation}>
2530
<>
2631
<ReadonlyHandle
2732
box={bbox}
@@ -83,40 +88,12 @@ export function ReadonlySelectHightlight({
8388
/>
8489
</>
8590
<>
86-
<OulineSide
87-
orientation="l"
88-
wh={wh}
89-
zoom={props.zoom}
90-
width={width}
91-
box={bbox}
92-
color={color_layer_readonly_highlight}
93-
/>
94-
<OulineSide
95-
orientation="t"
96-
wh={wh}
97-
zoom={props.zoom}
98-
width={width}
99-
box={bbox}
100-
color={color_layer_readonly_highlight}
101-
/>
102-
<OulineSide
103-
orientation="b"
104-
wh={wh}
105-
zoom={props.zoom}
106-
width={width}
107-
box={bbox}
108-
color={color_layer_readonly_highlight}
109-
/>
110-
<OulineSide
111-
orientation="r"
112-
wh={wh}
113-
zoom={props.zoom}
114-
width={width}
115-
box={bbox}
116-
color={color_layer_readonly_highlight}
117-
/>
91+
<OulineSide orientation="l" {...sideprops} />
92+
<OulineSide orientation="t" {...sideprops} />
93+
<OulineSide orientation="b" {...sideprops} />
94+
<OulineSide orientation="r" {...sideprops} />
11895
</>
119-
</div>
96+
</OverlayContainer>
12097
);
12198
}
12299

externals/design-sdk

externals/reflect-core

0 commit comments

Comments
 (0)