Skip to content

Commit

Permalink
Updating optional fields in html/image/text (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
cohitre authored Feb 29, 2024
1 parent c19d905 commit c097ba1
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/block-html/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/block-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@usewaypoint/block-html",
"version": "0.0.1",
"version": "0.0.2",
"description": "@usewaypoint/document compatible HTML component",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/block-html/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ export const HtmlPropsSchema = z.object({
color: COLOR_SCHEMA,
backgroundColor: COLOR_SCHEMA,
fontFamily: FONT_FAMILY_SCHEMA,
fontSize: z.number().min(0),
textAlign: z.enum(['left', 'right', 'center']).optional().nullable().default(null),
fontSize: z.number().min(0).optional().nullable(),
textAlign: z.enum(['left', 'right', 'center']).optional().nullable(),
padding: PADDING_SCHEMA,
})
.optional()
.nullable(),
props: z
.object({
contents: z.string(),
contents: z.string().optional().nullable(),
})
.optional()
.nullable(),
Expand Down
4 changes: 2 additions & 2 deletions packages/block-image/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/block-image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@usewaypoint/block-image",
"version": "0.0.3",
"version": "0.0.4",
"description": "@usewaypoint/document compatible Image component",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 1 addition & 3 deletions packages/block-image/src/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

exports[`block-image renders with default values 1`] = `
<DocumentFragment>
<div
style="text-align: center;"
>
<div>
<img
alt=""
src=""
Expand Down
2 changes: 1 addition & 1 deletion packages/block-image/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function Image({ style, props }: ImageProps) {
const sectionStyle: CSSProperties = {
padding: getPadding(style?.padding),
backgroundColor: style?.backgroundColor ?? undefined,
textAlign: style?.textAlign ?? 'center',
textAlign: style?.textAlign ?? undefined,
};

const linkHref = props?.linkHref ?? null;
Expand Down
4 changes: 2 additions & 2 deletions packages/block-text/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/block-text/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@usewaypoint/block-text",
"version": "0.0.1",
"version": "0.0.2",
"description": "@usewaypoint/document compatible Text component",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 1 addition & 3 deletions packages/block-text/src/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

exports[`block-text renders with default values 1`] = `
<DocumentFragment>
<div
style="font-size: 16px;"
/>
<div />
</DocumentFragment>
`;
6 changes: 3 additions & 3 deletions packages/block-text/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export const TextPropsSchema = z.object({
.object({
color: COLOR_SCHEMA,
backgroundColor: COLOR_SCHEMA,
fontSize: z.number().min(0).optional().nullable(),
fontSize: z.number().gte(0).optional().nullable(),
fontFamily: FONT_FAMILY_SCHEMA,
fontWeight: z.enum(['bold', 'normal']).nullable(),
fontWeight: z.enum(['bold', 'normal']).optional().nullable(),
textAlign: z.enum(['left', 'center', 'right']).optional().nullable(),
padding: PADDING_SCHEMA,
})
Expand All @@ -90,7 +90,7 @@ export function Text({ style, props }: TextProps) {
const wStyle: CSSProperties = {
color: style?.color ?? undefined,
backgroundColor: style?.backgroundColor ?? undefined,
fontSize: style?.fontSize ?? 16,
fontSize: style?.fontSize ?? undefined,
fontFamily: getFontFamily(style?.fontFamily),
fontWeight: style?.fontWeight ?? undefined,
textAlign: style?.textAlign ?? undefined,
Expand Down

0 comments on commit c097ba1

Please sign in to comment.