Skip to content

Visualize Your Ideas With Code

feat: add missing flexbox properties (#405)

Jacob4e78b4b2fe4d
diff --git a/packages/2d/src/components/Layout.ts b/packages/2d/src/components/Layout.ts
index 09ab1a6b..00820668 100644
--- a/packages/2d/src/components/Layout.ts
+++ b/packages/2d/src/components/Layout.ts
@@ -25,10 +25,10 @@ import {
tween,
} from '@motion-canvas/core/lib/tweening';
import {
- FlexAlign,
+ FlexItems,
FlexBasis,
FlexDirection,
- FlexJustify,
+ FlexContent,
FlexWrap,
LayoutMode,
DesiredLength,
@@ -79,8 +79,10 @@ export interface LayoutProps extends NodeProps {
shrink?: SignalValue<number>;
wrap?: SignalValue<FlexWrap>;
- justifyContent?: SignalValue<FlexJustify>;
- alignItems?: SignalValue<FlexAlign>;
+ justifyContent?: SignalValue<FlexContent>;
+ alignContent?: SignalValue<FlexContent>;
+ alignItems?: SignalValue<FlexItems>;
+ alignSelf?: SignalValue<FlexItems>;
rowGap?: SignalValue<Length>;
columnGap?: SignalValue<Length>;
gap?: SignalValue<Length>;
@@ -145,10 +147,16 @@ export class Layout extends Node {
@initial('normal')
@signal()
- public declare readonly justifyContent: SimpleSignal<FlexJustify, this>;
+ public declare readonly justifyContent: SimpleSignal<FlexContent, this>;
@initial('normal')
@signal()
- public declare readonly alignItems: SimpleSignal<FlexAlign, this>;
+ public declare readonly alignContent: SimpleSignal<FlexContent, this>;
+ @initial('normal')
+ @signal()
+ public declare readonly alignItems: SimpleSignal<FlexItems, this>;
+ @initial('normal')
+ @signal()
+ public declare readonly alignSelf: SimpleSignal<FlexItems, this>;
@initial(0)
@vector2Signal({x: 'columnGap', y: 'rowGap'})
public declare readonly gap: Vector2LengthSignal<this>;
@@ -747,7 +755,9 @@ export class Layout extends Node {
this.element.style.flexWrap = this.wrap();
this.element.style.justifyContent = this.justifyContent();
+ this.element.style.alignContent = this.alignContent();
this.element.style.alignItems = this.alignItems();
+ this.element.style.alignSelf = this.alignSelf();
this.element.style.columnGap = this.parseLength(this.gap.x());
this.element.style.rowGap = this.parseLength(this.gap.y());
diff --git a/packages/2d/src/partials/types.ts b/packages/2d/src/partials/types.ts
index a526cdfc..06815267 100644
--- a/packages/2d/src/partials/types.ts
+++ b/packages/2d/src/partials/types.ts
@@ -14,7 +14,7 @@ export type FlexBasis =
| 'fit-content'
| null;
-export type FlexJustify =
+export type FlexContent =
| 'normal'
| 'center'
| 'start'
@@ -24,7 +24,7 @@ export type FlexJustify =
| 'space-evenly'
| 'stretch';
-export type FlexAlign =
+export type FlexItems =
| 'normal'
| 'center'
| 'start'