-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
6,306 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
|
||
import { Button, Menu, MenuItem } from '@mui/material'; | ||
|
||
export default function ExamplesButton() { | ||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); | ||
const open = Boolean(anchorEl); | ||
const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
const select = (val: string) => { | ||
window.location.hash = `#sample/${val}`; | ||
handleClose(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Button onClick={handleOpen}>Samples</Button> | ||
<Menu | ||
id="basic-menu" | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={handleClose} | ||
MenuListProps={{ | ||
'aria-labelledby': 'basic-button', | ||
}} | ||
> | ||
<MenuItem onClick={() => select('one-time-password')}>one-time-password</MenuItem> | ||
<MenuItem onClick={() => select('order-ecomerce')}>order-ecomerce</MenuItem> | ||
<MenuItem onClick={() => select('post-metrics-report')}>post-metrics-report</MenuItem> | ||
<MenuItem onClick={() => select('reservation-reminder')}>reservation-reminder</MenuItem> | ||
<MenuItem onClick={() => select('reset-password')}>reset-password</MenuItem> | ||
<MenuItem onClick={() => select('respond-to-message')}>respond-to-message</MenuItem> | ||
<MenuItem onClick={() => select('subscription-receipt')}>subscription-receipt</MenuItem> | ||
</Menu> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import ONE_TIME_PASSCODE from './sample/one-time-passcode'; | ||
import ORDER_ECOMMERCE from './sample/order-ecommerce'; | ||
import POST_METRICS_REPORT from './sample/post-metrics-report'; | ||
import RESERVATION_REMINDER from './sample/reservation-reminder'; | ||
import RESET_PASSWORD from './sample/reset-password'; | ||
import RESPOND_TO_MESSAGE from './sample/respond-to-message'; | ||
import SUBSCRIPTION_RECEIPT from './sample/subscription-receipt'; | ||
|
||
export default function getConfiguration(template: string) { | ||
if (template.startsWith('#sample/')) { | ||
const sampleName = template.replace('#sample/', ''); | ||
switch (sampleName) { | ||
case 'one-time-password': | ||
return ONE_TIME_PASSCODE; | ||
case 'order-ecomerce': | ||
return ORDER_ECOMMERCE; | ||
case 'post-metrics-report': | ||
return POST_METRICS_REPORT; | ||
case 'reservation-reminder': | ||
return RESERVATION_REMINDER; | ||
case 'reset-password': | ||
return RESET_PASSWORD; | ||
case 'respond-to-message': | ||
return RESPOND_TO_MESSAGE; | ||
case 'subscription-receipt': | ||
return SUBSCRIPTION_RECEIPT; | ||
} | ||
} | ||
|
||
if (template.startsWith('#code/')) { | ||
const encodedString = template.replace('#sample/', ''); | ||
const configurationString = atob(encodedString); | ||
try { | ||
return JSON.parse(configurationString); | ||
} catch { | ||
console.error(`Couldn't load configuration from hash.`); | ||
} | ||
} | ||
|
||
const configurationString = localStorage.getItem('configuration'); | ||
if (typeof configurationString === 'string') { | ||
try { | ||
return JSON.parse(configurationString); | ||
} catch { | ||
console.error(`Couldn't load configuration from localStorage.`); | ||
} | ||
} | ||
|
||
return { | ||
root: { | ||
type: 'EmailLayout', | ||
data: { | ||
backdropColor: '#e5e7e5', | ||
canvasColor: '#FFFFFF', | ||
textColor: '#242424', | ||
accentColor: '#0b5499', | ||
fontFamily: 'MODERN_SANS', | ||
childrenIds: [], | ||
}, | ||
}, | ||
}; | ||
} |
Oops, something went wrong.