Skip to content

Commit

Permalink
feat(Gate): expand upon the And node and allow for more "gates" (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiduzo authored Dec 15, 2024
1 parent 844e778 commit ac7a687
Show file tree
Hide file tree
Showing 29 changed files with 473 additions and 278 deletions.
78 changes: 26 additions & 52 deletions apps/electron-app/src/common/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,45 @@
import { Button, DEFAULT_BUTTON_DATA } from '../render/components/react-flow/nodes/Button';
import { Counter, DEFAULT_COUNTER_DATA } from '../render/components/react-flow/nodes/Counter';
import { DEFAULT_FIGMA_DATA, Figma } from '../render/components/react-flow/nodes/Figma';
import { DEFAULT_COMPARE_DATA, Compare } from '../render/components/react-flow/nodes/Compare';
import { DEFAULT_INTERVAL_DATA, Interval } from '../render/components/react-flow/nodes/Interval';
import {
DEFAULT_OSCILLATOR_DATA,
Oscillator,
} from '../render/components/react-flow/nodes/Oscillator';
import { DEFAULT_TRIGGER_DATA, Trigger } from '../render/components/react-flow/nodes/Trigger';
import { DEFAULT_SMOOTH_DATA, Smooth } from '../render/components/react-flow/nodes/Smooth';
import { DEFAULT_LED_DATA, Led } from '../render/components/react-flow/nodes/Led';
import { DEFAULT_MATRIX_DATA, Matrix } from '../render/components/react-flow/nodes/matrix/Matrix';
import { DEFAULT_MOTION_DATA, Motion } from '../render/components/react-flow/nodes/Motion';
import { DEFAULT_MQTT_DATA, Mqtt } from '../render/components/react-flow/nodes/Mqtt';
import { DEFAULT_NOTE_DATA, Note } from '../render/components/react-flow/nodes/Note';
import { DEFAULT_MONITOR_DATA, Monitor } from '../render/components/react-flow/nodes/Monitor';
import { DEFAULT_PIEZO_DATA, Piezo } from '../render/components/react-flow/nodes/piezo/Piezo';
import { DEFAULT_RANGE_MAP_DATA, RangeMap } from '../render/components/react-flow/nodes/RangeMap';
import { DEFAULT_SENSOR_DATA, Sensor } from '../render/components/react-flow/nodes/Sensor';
import { DEFAULT_SERVO_DATA, Servo } from '../render/components/react-flow/nodes/Servo';
import { DEFAULT_RGB_DATA, Rgb } from '../render/components/react-flow/nodes/RGB';
import { And, DEFAULT_AND_DATA } from '../render/components/react-flow/nodes/And';
import { Button } from '../render/components/react-flow/nodes/Button';
import { Counter } from '../render/components/react-flow/nodes/Counter';
import { Compare } from '../render/components/react-flow/nodes/Compare';
import { Figma } from '../render/components/react-flow/nodes/Figma';
import { Interval } from '../render/components/react-flow/nodes/Interval';
import { Led } from '../render/components/react-flow/nodes/Led';
import { Matrix } from '../render/components/react-flow/nodes/matrix/Matrix';
import { Monitor } from '../render/components/react-flow/nodes/Monitor';
import { Motion } from '../render/components/react-flow/nodes/Motion';
import { Mqtt } from '../render/components/react-flow/nodes/Mqtt';
import { Note } from '../render/components/react-flow/nodes/Note';
import { Oscillator } from '../render/components/react-flow/nodes/Oscillator';
import { Piezo } from '../render/components/react-flow/nodes/piezo/Piezo';
import { RangeMap } from '../render/components/react-flow/nodes/RangeMap';
import { Rgb } from '../render/components/react-flow/nodes/RGB';
import { Sensor } from '../render/components/react-flow/nodes/Sensor';
import { Servo } from '../render/components/react-flow/nodes/Servo';
import { Smooth } from '../render/components/react-flow/nodes/Smooth';
import { Trigger } from '../render/components/react-flow/nodes/Trigger';
import { Gate } from '../render/components/react-flow/nodes/Gate';

export const NODE_TYPES = {
And: And,
Button: Button,
Compare: Compare,
Counter: Counter,
Monitor: Monitor,
Figma: Figma,
Compare: Compare,
Gate: Gate,
Interval: Interval,
Oscillator: Oscillator,
Trigger: Trigger,
Smooth: Smooth,
Led: Led,
Matrix: Matrix,
Monitor: Monitor,
Motion: Motion,
Mqtt: Mqtt,
Note: Note,
Oscillator: Oscillator,
Piezo: Piezo,
RangeMap: RangeMap,
Rgb: Rgb,
Sensor: Sensor,
Servo: Servo,
Smooth: Smooth,
Trigger: Trigger,
};

export type NodeType = keyof typeof NODE_TYPES;

export const DEFAULT_NODE_DATA = new Map<NodeType | string, Record<string, any>>();

DEFAULT_NODE_DATA.set('And', DEFAULT_AND_DATA);
DEFAULT_NODE_DATA.set('Button', DEFAULT_BUTTON_DATA);
DEFAULT_NODE_DATA.set('Counter', DEFAULT_COUNTER_DATA);
DEFAULT_NODE_DATA.set('Monitor', DEFAULT_MONITOR_DATA);
DEFAULT_NODE_DATA.set('Figma', DEFAULT_FIGMA_DATA);
DEFAULT_NODE_DATA.set('Compare', DEFAULT_COMPARE_DATA);
DEFAULT_NODE_DATA.set('Interval', DEFAULT_INTERVAL_DATA);
DEFAULT_NODE_DATA.set('Oscillator', DEFAULT_OSCILLATOR_DATA);
DEFAULT_NODE_DATA.set('Trigger', DEFAULT_TRIGGER_DATA);
DEFAULT_NODE_DATA.set('Smooth', DEFAULT_SMOOTH_DATA);
DEFAULT_NODE_DATA.set('Led', DEFAULT_LED_DATA);
DEFAULT_NODE_DATA.set('Matrix', DEFAULT_MATRIX_DATA);
DEFAULT_NODE_DATA.set('Motion', DEFAULT_MOTION_DATA);
DEFAULT_NODE_DATA.set('Mqtt', DEFAULT_MQTT_DATA);
DEFAULT_NODE_DATA.set('Note', DEFAULT_NOTE_DATA);
DEFAULT_NODE_DATA.set('Piezo', DEFAULT_PIEZO_DATA);
DEFAULT_NODE_DATA.set('RangeMap', DEFAULT_RANGE_MAP_DATA);
DEFAULT_NODE_DATA.set('Rgb', DEFAULT_RGB_DATA);
DEFAULT_NODE_DATA.set('Sensor', DEFAULT_SENSOR_DATA);
DEFAULT_NODE_DATA.set('Servo', DEFAULT_SERVO_DATA);
80 changes: 0 additions & 80 deletions apps/electron-app/src/render/components/react-flow/nodes/And.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ function Settings() {
}

type Props = BaseNode<ButtonData>;
export const DEFAULT_BUTTON_DATA: Props['data'] = {
holdtime: 500,
isPulldown: false,
isPullup: false,
invert: false,
pin: 6,
label: 'Button',
Button.defaultProps = {
data: {
holdtime: 500,
isPulldown: false,
isPullup: false,
invert: false,
pin: 6,
label: 'Button',
} satisfies Props['data'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ function Settings() {
}

type Props = BaseNode<CompareData>;
export const DEFAULT_COMPARE_DATA: Props['data'] = {
label: 'compare',
validator: 'boolean',
Compare.defaultProps = {
data: {
label: 'compare',
validator: 'boolean',
} satisfies Props['data'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function Value() {
}

type Props = BaseNode<CounterData>;
export const DEFAULT_COUNTER_DATA: Props['data'] = {
label: 'Counter',
Counter.defaultProps = {
data: {
label: 'Counter',
} satisfies Props['data'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,13 @@ function Value(props: { variable?: FigmaVariable; hasVariables: boolean }) {

type Props = BaseNode<FigmaData>;
const DEFAULT_COLOR: RGBA = { r: 0, g: 0, b: 0, a: 1 };
export const DEFAULT_FIGMA_DATA: Props['data'] = {
label: 'Figma',
variableId: '',
Figma.defaultProps = {
data: {
label: 'Figma',
variableId: '',
} satisfies Props['data'],
};

export const DEFAULT_FIGMA_VALUE_PER_TYPE: Record<FigmaVariable['resolvedType'], unknown> = {
BOOLEAN: false,
FLOAT: 0,
Expand Down
Loading

0 comments on commit ac7a687

Please sign in to comment.