Skip to content

A free and open-source block-based email template builder.

Fixing share button and fixing default text-align on block-button (#52)

cohitre9b7a4bb94b47
diff --git a/packages/block-button/package-lock.json b/packages/block-button/package-lock.json
index 9213b9b..67fcd70 100644
--- a/packages/block-button/package-lock.json
+++ b/packages/block-button/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@usewaypoint/block-button",
- "version": "0.0.1",
+ "version": "0.0.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@usewaypoint/block-button",
- "version": "0.0.1",
+ "version": "0.0.2",
"license": "MIT",
"devDependencies": {
"@testing-library/react": "^14.2.1"
diff --git a/packages/block-button/package.json b/packages/block-button/package.json
index d09a5db..d453dd8 100644
--- a/packages/block-button/package.json
+++ b/packages/block-button/package.json
@@ -1,6 +1,6 @@
{
"name": "@usewaypoint/block-button",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "@usewaypoint/document compatible Button component",
"main": "dist/index.js",
"types": "dist/index.d.ts",
diff --git a/packages/block-button/src/__snapshots__/index.spec.tsx.snap b/packages/block-button/src/__snapshots__/index.spec.tsx.snap
index 647b6ff..5f8ef61 100644
--- a/packages/block-button/src/__snapshots__/index.spec.tsx.snap
+++ b/packages/block-button/src/__snapshots__/index.spec.tsx.snap
@@ -2,9 +2,7 @@
exports[`block-button renders with default values 1`] = `
<DocumentFragment>
- <div
- style="text-align: center;"
- >
+ <div>
<a
href=""
style="color: rgb(255, 255, 255); font-size: 16px; font-weight: bold; background-color: rgb(153, 153, 153); border-radius: 4px; display: inline-block; padding: 12px 20px; text-decoration: none;"
diff --git a/packages/block-button/src/index.tsx b/packages/block-button/src/index.tsx
index 09b6957..5605a00 100644
--- a/packages/block-button/src/index.tsx
+++ b/packages/block-button/src/index.tsx
@@ -137,7 +137,7 @@ export function Button({ style, props }: ButtonProps) {
const textRaise = (padding[1] * 2 * 3) / 4;
const wrapperStyle: CSSProperties = {
backgroundColor: style?.backgroundColor ?? undefined,
- textAlign: style?.textAlign ?? 'center',
+ textAlign: style?.textAlign ?? undefined,
padding: getPadding(style?.padding),
};
const linkStyle: CSSProperties = {
diff --git a/packages/editor-sample/package-lock.json b/packages/editor-sample/package-lock.json
index 0208f84..fb3c6c4 100644
--- a/packages/editor-sample/package-lock.json
+++ b/packages/editor-sample/package-lock.json
@@ -13,7 +13,7 @@
"@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10",
"@usewaypoint/block-avatar": "^0.0.1",
- "@usewaypoint/block-button": "^0.0.1",
+ "@usewaypoint/block-button": "^0.0.2",
"@usewaypoint/block-columns-container": "^0.0.2",
"@usewaypoint/block-container": "^0.0.1",
"@usewaypoint/block-divider": "^0.0.3",
@@ -2021,9 +2021,9 @@
}
},
"node_modules/@usewaypoint/block-button": {
- "version": "0.0.1",
- "resolved": "https://registry.npmjs.org/@usewaypoint/block-button/-/block-button-0.0.1.tgz",
- "integrity": "sha512-aQU14l7XjE3dOsu5yCS9tUqjObJkiBtxzsyloFU3eeD/lErLhZDWZf8LQ36HCiH+I7Zt5vEhnmOTN5vtjg4B/w==",
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/@usewaypoint/block-button/-/block-button-0.0.2.tgz",
+ "integrity": "sha512-WzWlJoJBiVfI3Iak9JPey7u/hJIkxXuhuAI6Y10ef795Panyr1GxQbdH2//fZtajjGJ1SjJStXpz6nPEd8wArg==",
"peerDependencies": {
"react": "^16 || ^17 || ^18",
"zod": "^1 || ^2 || ^3"
diff --git a/packages/editor-sample/package.json b/packages/editor-sample/package.json
index 7e47100..bd63c7c 100644
--- a/packages/editor-sample/package.json
+++ b/packages/editor-sample/package.json
@@ -13,7 +13,7 @@
"@mui/icons-material": "^5.15.10",
"@mui/material": "^5.15.10",
"@usewaypoint/block-avatar": "^0.0.1",
- "@usewaypoint/block-button": "^0.0.1",
+ "@usewaypoint/block-button": "^0.0.2",
"@usewaypoint/block-columns-container": "^0.0.2",
"@usewaypoint/block-container": "^0.0.1",
"@usewaypoint/block-divider": "^0.0.3",
diff --git a/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsx b/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsx
index b64d79b..273f8ac 100644
--- a/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsx
+++ b/packages/editor-sample/src/App/TemplatePanel/ShareButton.tsx
@@ -10,14 +10,9 @@ export default function ShareButton() {
const [message, setMessage] = useState<string | null>(null);
const onClick = async () => {
- const c = JSON.stringify(document);
- location.hash = `#${btoa(c)}`;
- if (navigator.clipboard) {
- await navigator.clipboard.writeText(location.href.toString());
- setMessage('The configuration URL was copied to your clipboard');
- } else {
- setMessage('The URL was updated. You can copy it to share');
- }
+ const c = encodeURIComponent(JSON.stringify(document));
+ location.hash = `#code/${btoa(c)}`;
+ setMessage('The URL was updated. You can copy it to share');
};
const onClose = () => {
diff --git a/packages/editor-sample/src/getConfiguration/index.tsx b/packages/editor-sample/src/getConfiguration/index.tsx
index 1a7d69f..c8972ee 100644
--- a/packages/editor-sample/src/getConfiguration/index.tsx
+++ b/packages/editor-sample/src/getConfiguration/index.tsx
@@ -29,8 +29,8 @@ export default function getConfiguration(template: string) {
}
if (template.startsWith('#code/')) {
- const encodedString = template.replace('#sample/', '');
- const configurationString = atob(encodedString);
+ const encodedString = template.replace('#code/', '');
+ const configurationString = decodeURIComponent(atob(encodedString));
try {
return JSON.parse(configurationString);
} catch {