Skip to content

Commit

Permalink
Fixing CI and some typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
cohitre committed Feb 27, 2024
1 parent c2a470f commit 235a75c
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 46 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,7 @@ jobs:
node-version: 20
cache: 'npm'
- run: npm ci
- run: (cd ./packages/block-avatar;npm ci)
- run: (cd ./packages/block-button;npm ci)
- run: (cd ./packages/block-divider;npm ci)
- run: (cd ./packages/block-heading;npm ci)
- run: (cd ./packages/block-html;npm ci)
- run: (cd ./packages/block-image;npm ci)
- run: (cd ./packages/block-spacer;npm ci)
- run: (cd ./packages/block-text;npm ci)
- run: (cd ./packages/document-core;npm ci)
- run: (cd ./packages/editor-sample;npm ci)
- run: npx eslint .
- run: npx prettier . --check
- run: npx tsc --noEmit
- run: bash scripts/check_typescript.sh
- run: npm test
4 changes: 2 additions & 2 deletions packages/document-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/document-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@usewaypoint/document-core",
"version": "0.0.1",
"version": "0.0.2",
"description": "Tools to render waypoint-style documents (core package)",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { BaseZodDictionary, BlockConfiguration, DocumentBlocksDictionary } from
*/
export default function buildBlockComponent<T extends BaseZodDictionary>(blocks: DocumentBlocksDictionary<T>) {
return function BlockComponent({ type, data }: BlockConfiguration<T>) {
return React.createElement(blocks[type].Component, data);
const Component = blocks[type].Component;
return <Component {...data} />;
};
}
3 changes: 1 addition & 2 deletions packages/document-core/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';
import { z } from 'zod';

export type BaseZodDictionary = { [name: string]: z.AnyZodObject };
export type DocumentBlocksDictionary<T extends BaseZodDictionary> = {
[K in keyof T]: {
schema: T[K];
Component: (props: z.infer<T[K]>) => React.ReactNode;
Component: (props: z.infer<T[K]>) => JSX.Element;
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';

import { HeightOutlined } from '@mui/icons-material';
import { SpacerProps, SpacerPropsSchema } from '@usewaypoint/block-spacer';
import { SpacerProps, SpacerPropsDefaults, SpacerPropsSchema } from '@usewaypoint/block-spacer';

import BaseSidebarPanel from './helpers/BaseSidebarPanel';
import SliderInput from './helpers/inputs/SliderInput';
Expand Down Expand Up @@ -32,7 +32,7 @@ export default function SpacerSidebarPanel({ data, setData }: SpacerSidebarPanel
step={4}
min={4}
max={128}
defaultValue={data.props.height ?? 16}
defaultValue={data.props?.height ?? SpacerPropsDefaults.height}
onChange={(height) => updateData({ ...data, props: { ...data.props, height } })}
/>
</BaseSidebarPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function TextSidebarPanel({ data, setData }: TextSidebarPanelProp
<TextInput
label="Content"
rows={5}
defaultValue={data.props.text}
defaultValue={data.props?.text ?? ''}
onChange={(text) => updateData({ ...data, props: { ...data.props, text } })}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type TCommonProps = {
style: Record<string, unknown>;
};

export function addReaderBlockWrapper<TProps extends TCommonProps>(ChildComponent: (props: TProps) => React.ReactNode) {
export function addReaderBlockWrapper<TProps extends TCommonProps>(ChildComponent: (props: TProps) => JSX.Element) {
return (props: TProps) => {
return (
<ReaderBlockWrapper style={props.style}>
Expand All @@ -18,7 +18,7 @@ export function addReaderBlockWrapper<TProps extends TCommonProps>(ChildComponen
};
}

export function addEditorBlockWrapper<TProps extends TCommonProps>(ChildComponent: (props: TProps) => React.ReactNode) {
export function addEditorBlockWrapper<TProps extends TCommonProps>(ChildComponent: (props: TProps) => JSX.Element) {
return (props: TProps) => {
return (
<EditorBlockWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const ONE_TIME_PASSCODE: TEditorConfiguration = {
textAlign: 'center',
},
props: {
height: 24,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_jc7ZfPvdHJ6rtH1W/&.png',
alt: '',
linkHref: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: null,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_FBfTeYhbdXtqYpCA/kiran-ck-6rXpQzfCYlw-unsplash.jpg',
alt: '',
linkHref: null,
Expand Down Expand Up @@ -366,8 +364,6 @@ const ORDER_ECOMMERCE: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: null,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_vjmjV2NrQ52h1iLj/coupon.png',
alt: '',
linkHref: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const POST_METRICS_REPORT: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: 16,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_n3eLjsf37dcjFaj5/Narrative.png',
alt: '',
linkHref: null,
Expand Down Expand Up @@ -80,8 +78,7 @@ const POST_METRICS_REPORT: TEditorConfiguration = {
size: 32,
shape: 'circle',
imageUrl: 'https://ui-avatars.com/api/?name=John+Doe',
fallbackText: 'Jordan',
fallbackColor: null,
alt: 'Jordan',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const RESERVATION_REMINDER: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: 32,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_RAFATLGe3CN1wDsb/birdhouse.png',
alt: '',
linkHref: null,
Expand Down Expand Up @@ -111,8 +109,7 @@ const RESERVATION_REMINDER: TEditorConfiguration = {
size: 64,
shape: 'circle',
imageUrl: '',
fallbackText: 'Elaina',
fallbackColor: null,
alt: 'Elaina',
},
},
},
Expand Down Expand Up @@ -305,8 +302,6 @@ const RESERVATION_REMINDER: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: null,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_QWeWcucRbjPqoewY/L1030293.jpg',
alt: 'Photo',
linkHref: 'https://example.usewaypoint.com/listings/r029348209842',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ const RESET_PASSWORD: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: 40,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_w9brVHZobEBhsJSK/marketbase.png',
alt: '',
linkHref: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ const RESPOND_TO_MESSAGE: TEditorConfiguration = {
textAlign: null,
},
props: {
height: 32,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_hW6RusynHUNTKoLm/boop.png',
alt: '',
linkHref: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const SUBSCRIPTION_RECEIPT: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: 18,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_9TcdHLq5SpEkRADB/REMIX.png',
alt: 'Remix',
linkHref: 'https://remix.example.com',
Expand Down Expand Up @@ -297,8 +295,6 @@ const SUBSCRIPTION_RECEIPT: TEditorConfiguration = {
textAlign: 'left',
},
props: {
height: null,
width: null,
url: 'https://d1iiu589g39o6c.cloudfront.net/live/platforms/platform_A9wwKSL6EV6orh6f/images/wptemplateimage_8yUGBZcXaAtTEofB/invoice-skeleton.png',
alt: 'Your invoice has been paid.',
linkHref: 'http://remix.example.com/receipt/1923-2093',
Expand Down
10 changes: 10 additions & 0 deletions scripts/check_typescript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(cd ./packages/block-avatar;npm ci;tsc --noEmit)
(cd ./packages/block-button;npm ci;tsc --noEmit)
(cd ./packages/block-divider;npm ci;tsc --noEmit)
(cd ./packages/block-heading;npm ci;tsc --noEmit)
(cd ./packages/block-html;npm ci;tsc --noEmit)
(cd ./packages/block-image;npm ci;tsc --noEmit)
(cd ./packages/block-spacer;npm ci;tsc --noEmit)
(cd ./packages/block-text;npm ci;tsc --noEmit)
(cd ./packages/document-core;npm ci;tsc --noEmit)
(cd ./packages/editor-sample;npm ci;tsc --noEmit)

0 comments on commit 235a75c

Please sign in to comment.