Skip to content

March release #2 #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/css-blend-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CSS - Blend mode

## Supported types

```
normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity
```

## Warning Lack of browser support on SVG element.

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

### References

- [`mix-blend-mode`](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode)
- [`background-blend-mode`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-blend-mode)
60 changes: 60 additions & 0 deletions docs/css-multiple-background.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "CSS How to handle multiple background fills"
version: 0.1.0
revision: 1
---

# How to handle multiple background fills

## Definition of `"multiple background fills"`

- one or none active solid fill
- one or more gradient fill above solid fill
- one or more image fill

## Possible combinations

single solid fill

```css
._1 {
background: #fff;
}
._2 {
background-color: #fff;
}
```

single solid fill with single gradient fill

```css
._1 {
background-color: #fff;
background-image: linear-gradient(to bottom, #fff, #fff);
}

._2 {
background: #fff;
background-image: linear-gradient(to bottom, #fff, #fff);
}
```

no solid fill with single gradient fill

```css
._1 {
background: linear-gradient(to bottom, #fff, #fff);
}

._2 {
background-image: linear-gradient(to bottom, #fff, #fff);
}
```

no solid fill with multiple gradient fill

```css
._1 {
background: linear-gradient(to bottom, #fff, #fff), linear-gradient(to bottom, #fff, #fff);
}
```
26 changes: 26 additions & 0 deletions docs/css-text-gradient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: "CSS Gradient on text layer"
version: 0.1.0
revision: 1
---

# CSS - Gradient on Text Layer

Applying a gradient to a text fill is quite different from simply giving a color to a text.
Yet hooray CSS, it is much more simple than other platforms (flutter, android, ...)

**How to**

```css
h1 {
font-size: 72px;
background: -webkit-linear-gradient(#eee, #333);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
```

### References

- https://cssgradient.io/blog/css-gradient-text/
- https://github.com/gridaco/designto-code/issues/84
11 changes: 11 additions & 0 deletions docs/css-text-vertical-align.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "CSS Vertically align text content"
version: 0.1.0
revision: 1
---

# Vertical align of text content

### References

- https://stackoverflow.com/questions/8865458/how-do-i-vertically-center-text-with-css
31 changes: 31 additions & 0 deletions docs/figma-rotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,37 @@ revision: 1

> Figma rotation from [figma plugin docs](https://www.figma.com/plugin-docs/api/properties/nodes-rotation/#docsNav)

## [Note] The rotation value needs to be inverted on the client side.

to rotate something to the clockwise direction,

- figma: -n
- client: +n (css)

the transform origin

- figma: not specified (always top left)
- client: top left

**so the conversion from figma to css will be like below**

```
# figma
{
x: 100,
y: 100,
rotation: 10,
}

# css
.rotate-n {
top: 100;
left: 100;
transform: rotate(-10deg);
transform-origin: top left;
}
```

## Transform?

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`.
Expand Down
1 change: 1 addition & 0 deletions editor-packages/editor-canvas/canvas/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export function Canvas({
).map((h) => ({
id: h.id,
xywh: [h.absoluteX, h.absoluteY, h.width, h.height],
rotation: h.rotation,
}))
: []
}
Expand Down
5 changes: 4 additions & 1 deletion editor-packages/editor-canvas/canvas/hud-surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface DisplayNodeMeta {
absoluteY: number;
width: number;
height: number;
rotation: number;
}

export function HudSurface({
Expand All @@ -41,7 +42,7 @@ export function HudSurface({
}: {
offset: XY;
zoom: number;
highlights: { id: string; xywh: XYWH }[];
highlights: { id: string; xywh: XYWH; rotation: number }[];
labelDisplayNodes: DisplayNodeMeta[];
selectedNodes: DisplayNodeMeta[];
hide: boolean;
Expand Down Expand Up @@ -102,6 +103,7 @@ export function HudSurface({
key={h.id}
type="xywhr"
xywh={h.xywh}
rotation={h.rotation}
zoom={zoom}
width={2}
/>
Expand All @@ -121,6 +123,7 @@ export function HudSurface({
key={s.id}
type="xywhr"
xywh={xywh}
rotation={s.rotation}
zoom={zoom}
width={1}
/>
Expand Down
51 changes: 16 additions & 35 deletions editor-packages/editor-canvas/overlay/hover-outline-hightlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,27 @@ import React from "react";
import { color_layer_highlight } from "../theme";
import { get_boinding_box } from "./math";
import { OulineSide } from "./outline-side";
import { OverlayContainer } from "./overlay-container";
import type { OutlineProps } from "./types";

export function HoverOutlineHighlight({ width = 1, ...props }: OutlineProps) {
const { xywh, zoom } = props;
const { xywh, zoom, rotation } = props;
const bbox = get_boinding_box({ xywh, scale: zoom });
const wh: [number, number] = [xywh[2], xywh[3]];
const vprops = {
wh: wh,
zoom: props.zoom,
width: width,
box: bbox,
color: color_layer_highlight,
};

return (
<>
<OulineSide
orientation="l"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_highlight}
/>
<OulineSide
orientation="t"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_highlight}
/>
<OulineSide
orientation="b"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_highlight}
/>
<OulineSide
orientation="r"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_highlight}
/>
</>
<OverlayContainer xywh={bbox} rotation={rotation}>
<OulineSide orientation="l" {...vprops} />
<OulineSide orientation="t" {...vprops} />
<OulineSide orientation="b" {...vprops} />
<OulineSide orientation="r" {...vprops} />
</OverlayContainer>
);
}
2 changes: 2 additions & 0 deletions editor-packages/editor-canvas/overlay/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export function get_boinding_box({
scale: number;
}): [number, number, number, number] {
const [x, y, w, h] = xywh;

// return the bounding box in [number, number, number, number] form with givven x, y, w, h, rotation and scale.
const [x1, y1, x2, y2] = [
x * scale,
y * scale,
Expand Down
30 changes: 30 additions & 0 deletions editor-packages/editor-canvas/overlay/overlay-container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";

/**
* @default - TODO: rotation not supported
* @returns
*/
export function OverlayContainer({
xywh,
rotation = 0,
children,
}: {
xywh: [number, number, number, number];
rotation: number;
children: React.ReactNode;
}) {
// const [x, y, w, h] = xywh;
return (
<div
id="overlay-container"
style={{
pointerEvents: "none",
willChange: "transform, opacity",
// transformOrigin: `${x}px ${y}px`,
// transform: `rotate(${-rotation}deg)`,
}}
>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@ import type { OutlineProps } from "./types";
import { color_layer_readonly_highlight } from "../theme";
import { get_boinding_box } from "./math";
import { OulineSide } from "./outline-side";
import { OverlayContainer } from "./overlay-container";

export function ReadonlySelectHightlight({
width = 1,
...props
}: OutlineProps) {
const { xywh, zoom } = props;
const { xywh, zoom, rotation } = props;
const bbox = get_boinding_box({ xywh, scale: zoom });
const wh: [number, number] = [xywh[2], xywh[3]];

const handle_outline_width = width;
const handle_size = 3;
const dot_size = 4;

const sideprops = {
wh: wh,
zoom: props.zoom,
width: width,
box: bbox,
color: color_layer_readonly_highlight,
};

return (
<div
style={{
pointerEvents: "none",
}}
>
<OverlayContainer xywh={bbox} rotation={rotation}>
<>
<ReadonlyHandle
box={bbox}
Expand Down Expand Up @@ -83,40 +88,12 @@ export function ReadonlySelectHightlight({
/>
</>
<>
<OulineSide
orientation="l"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_readonly_highlight}
/>
<OulineSide
orientation="t"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_readonly_highlight}
/>
<OulineSide
orientation="b"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_readonly_highlight}
/>
<OulineSide
orientation="r"
wh={wh}
zoom={props.zoom}
width={width}
box={bbox}
color={color_layer_readonly_highlight}
/>
<OulineSide orientation="l" {...sideprops} />
<OulineSide orientation="t" {...sideprops} />
<OulineSide orientation="b" {...sideprops} />
<OulineSide orientation="r" {...sideprops} />
</>
</div>
</OverlayContainer>
);
}

Expand Down
2 changes: 1 addition & 1 deletion externals/design-sdk
2 changes: 1 addition & 1 deletion externals/reflect-core
Loading