@maily-to/shared 0.0.2 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -5
- package/dist/index.cjs +1081 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1040 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1006 -80
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +922 -131
- package/dist/index.mjs.map +1 -1
- package/package.json +31 -26
- package/readme.md +4 -4
- package/dist/index.d.ts +0 -114
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -213
- package/dist/index.js.map +0 -1
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DEFAULT_FONT: FontProps","DEFAULT_RENDERER_THEME: RendererThemeOptions","DEFAULT_EDITOR_THEME: EditorThemeOptions","name: `--mly-${string}`","value: any","theme: EditorThemeOptions","font: Font"],"sources":["../src/theme.ts","../src/css-variables.ts","../src/font.ts"],"sourcesContent":["import type * as CSS from 'csstype';\n\nexport const allowedFallbackFonts = [\n 'Arial',\n 'Helvetica',\n 'Verdana',\n 'Georgia',\n 'Times New Roman',\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n] as const;\n\nexport type FallbackFont = (typeof allowedFallbackFonts)[number];\n\nexport const allowedFontFormats = [\n 'woff',\n 'woff2',\n 'truetype',\n 'opentype',\n 'embedded-opentype',\n 'svg',\n] as const;\n\nexport type FontFormat = (typeof allowedFontFormats)[number];\n\ntype FontWeight = CSS.Properties['fontWeight'];\ntype FontStyle = CSS.Properties['fontStyle'];\n\nexport interface FontProps {\n /** The font you want to use. NOTE: Do not insert multiple fonts here, use fallbackFontFamily for that */\n fontFamily: string;\n /** An array is possible, but the order of the array is the priority order */\n fallbackFontFamily: FallbackFont;\n /** Not all clients support web fonts. For support check: https://www.caniemail.com/features/css-at-font-face/ */\n webFont?: {\n url: string;\n format: FontFormat;\n };\n /** Default: 'normal' */\n fontStyle?: FontStyle;\n /** Default: 400 */\n fontWeight?: FontWeight;\n}\n\nexport interface BaseThemeOptions {\n container?: Partial<\n Pick<\n CSS.Properties,\n | 'backgroundColor'\n | 'maxWidth'\n | 'minWidth'\n | 'paddingTop'\n | 'paddingRight'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'borderRadius'\n | 'borderWidth'\n | 'borderColor'\n >\n >;\n body?: Partial<\n Pick<\n CSS.Properties,\n | 'backgroundColor'\n | 'paddingTop'\n | 'paddingRight'\n | 'paddingBottom'\n | 'paddingLeft'\n >\n >;\n button?: Partial<\n Pick<\n CSS.Properties,\n | 'paddingTop'\n | 'paddingRight'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'backgroundColor'\n | 'color'\n >\n >;\n link?: Partial<Pick<CSS.Properties, 'color'>>;\n font?: Pick<\n FontProps,\n 'fontFamily' | 'fallbackFontFamily' | 'webFont'\n > | null;\n}\n\n/**\n * The theme options for the editor.\n * currently, we don't allow any customizations for the colors in the editor.\n * that's why we have a separate theme for the editor.\n */\nexport interface EditorThemeOptions extends BaseThemeOptions {}\n\n/**\n * The theme options for the renderer.\n * currently, we don't allow any customizations for the colors in the editor.\n * that's why we have a separate theme for the renderer.\n */\nexport interface RendererThemeOptions extends BaseThemeOptions {\n colors?: Partial<{\n heading: string;\n paragraph: string;\n horizontal: string;\n footer: string;\n blockquoteBorder: string;\n codeBackground: string;\n codeText: string;\n linkCardTitle: string;\n linkCardDescription: string;\n linkCardBadgeText: string;\n linkCardBadgeBackground: string;\n linkCardSubTitle: string;\n }>;\n fontSize?: Partial<{\n paragraph: Partial<{\n size: string;\n lineHeight: string;\n }>;\n footer: Partial<{\n size: string;\n lineHeight: string;\n }>;\n }>;\n}\n\nexport const DEFAULT_FONT: FontProps = {\n fallbackFontFamily: 'sans-serif',\n fontFamily: 'Inter',\n webFont: {\n url: 'https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19',\n format: 'woff2',\n },\n};\n\nexport const DEFAULT_LINK_TEXT_COLOR = '#111827';\n\nexport const DEFAULT_RENDERER_THEME: RendererThemeOptions = {\n colors: {\n heading: '#111827',\n paragraph: '#374151',\n horizontal: '#EAEAEA',\n footer: '#64748B',\n blockquoteBorder: '#D1D5DB',\n codeBackground: '#EFEFEF',\n codeText: '#111827',\n linkCardTitle: '#111827',\n linkCardDescription: '#6B7280',\n linkCardBadgeText: '#111827',\n linkCardBadgeBackground: '#FEF08A',\n linkCardSubTitle: '#6B7280',\n },\n fontSize: {\n paragraph: {\n size: '15px',\n lineHeight: '26.25px',\n },\n footer: {\n size: '14px',\n lineHeight: '24px',\n },\n },\n\n container: {\n backgroundColor: '#ffffff',\n maxWidth: '600px',\n minWidth: '300px',\n paddingTop: '0.5rem',\n paddingRight: '0.5rem',\n paddingBottom: '0.5rem',\n paddingLeft: '0.5rem',\n\n borderRadius: '0px',\n borderWidth: '0px',\n borderColor: 'transparent',\n },\n body: {\n backgroundColor: '#ffffff',\n\n paddingTop: '0px',\n paddingRight: '0px',\n paddingBottom: '0px',\n paddingLeft: '0px',\n },\n button: {\n backgroundColor: '#000000',\n color: '#ffffff',\n paddingTop: '10px',\n paddingRight: '32px',\n paddingBottom: '10px',\n paddingLeft: '32px',\n },\n link: {\n color: DEFAULT_LINK_TEXT_COLOR,\n },\n font: DEFAULT_FONT,\n};\n\nexport const DEFAULT_EDITOR_THEME: EditorThemeOptions = {\n container: {\n backgroundColor: '#ffffff',\n maxWidth: '600px',\n minWidth: '300px',\n paddingTop: '8px',\n paddingRight: '8px',\n paddingBottom: '8px',\n paddingLeft: '8px',\n\n borderRadius: '0px',\n borderWidth: '0px',\n borderColor: 'transparent',\n },\n body: {\n backgroundColor: '#ffffff',\n\n paddingTop: '0px',\n paddingRight: '0px',\n paddingBottom: '0px',\n paddingLeft: '0px',\n },\n button: {\n backgroundColor: '#000000',\n color: '#ffffff',\n paddingTop: '10px',\n paddingRight: '32px',\n paddingBottom: '10px',\n paddingLeft: '32px',\n },\n link: {\n color: DEFAULT_LINK_TEXT_COLOR,\n },\n font: DEFAULT_FONT,\n};\n","import type * as CSS from 'csstype';\nimport { DEFAULT_FONT, type EditorThemeOptions } from './theme';\n\ndeclare module 'csstype' {\n interface Properties {\n [index: `--mly-${string}`]: any;\n }\n}\n\n/**\n * if the value is undefined, it will return an empty object\n * so that we don't override the default value\n * @param name - The name of the CSS variable\n * @param value - The value of the CSS variable\n * @returns The CSS variable value\n */\nexport function getVariableValue(\n name: `--mly-${string}`,\n value: any\n): CSS.Properties {\n if (value === undefined || value === null || value === '') {\n return {};\n }\n\n return {\n [name]: value,\n };\n}\n\n/**\n * Get the CSS variables for the theme\n * @param theme - The theme\n * @returns The CSS variables\n * @example\n * ```ts\n * const theme = {\n * body: {\n * backgroundColor: 'red',\n * },\n * };\n *\n * const cssVariables = getCssVariables(theme);\n *\n * console.log(cssVariables);\n * // { '--mly-body-background-color': 'red' }\n */\nexport function getMailyCssVariables(\n theme: EditorThemeOptions\n): CSS.Properties {\n const font = theme.font || DEFAULT_FONT;\n\n return {\n ...getVariableValue(\n '--mly-body-background-color',\n theme.body?.backgroundColor\n ),\n ...getVariableValue('--mly-body-padding-top', theme.body?.paddingTop),\n ...getVariableValue('--mly-body-padding-right', theme.body?.paddingRight),\n ...getVariableValue('--mly-body-padding-bottom', theme.body?.paddingBottom),\n ...getVariableValue('--mly-body-padding-left', theme.body?.paddingLeft),\n\n ...getVariableValue(\n '--mly-container-background-color',\n theme.container?.backgroundColor\n ),\n ...getVariableValue('--mly-container-max-width', theme.container?.maxWidth),\n ...getVariableValue('--mly-container-min-width', theme.container?.minWidth),\n\n ...getVariableValue(\n '--mly-container-padding-top',\n theme.container?.paddingTop\n ),\n ...getVariableValue(\n '--mly-container-padding-right',\n theme.container?.paddingRight\n ),\n ...getVariableValue(\n '--mly-container-padding-bottom',\n theme.container?.paddingBottom\n ),\n ...getVariableValue(\n '--mly-container-padding-left',\n theme.container?.paddingLeft\n ),\n\n ...getVariableValue(\n '--mly-container-border-radius',\n theme.container?.borderRadius\n ),\n ...getVariableValue(\n '--mly-container-border-width',\n theme.container?.borderWidth\n ),\n ...getVariableValue(\n '--mly-container-border-color',\n theme.container?.borderColor\n ),\n\n ...getVariableValue(\n '--mly-button-background-color',\n theme.button?.backgroundColor\n ),\n ...getVariableValue('--mly-button-text-color', theme.button?.color),\n ...getVariableValue('--mly-button-padding-top', theme.button?.paddingTop),\n ...getVariableValue(\n '--mly-button-padding-right',\n theme.button?.paddingRight\n ),\n ...getVariableValue(\n '--mly-button-padding-bottom',\n theme.button?.paddingBottom\n ),\n ...getVariableValue('--mly-button-padding-left', theme.button?.paddingLeft),\n\n ...getVariableValue('--mly-link-color', theme.link?.color),\n\n ...getVariableValue('--mly-font-family', font.fontFamily),\n ...getVariableValue('--mly-font-fallback-family', font.fallbackFontFamily),\n '--mly-font': `var(--mly-font-family), var(--mly-font-fallback-family)`,\n };\n}\n","import type { FontProps } from './theme';\n\ntype Font = Pick<FontProps, 'fontFamily' | 'fallbackFontFamily' | 'webFont'>;\n\nexport function loadFont(font: Font): void {\n const style = fontStyle(font);\n\n const styleElement = document.createElement('style');\n styleElement.textContent = style;\n document.head.appendChild(styleElement);\n}\n\nexport function fontStyle(font: Font): string {\n const { fontFamily, fallbackFontFamily, webFont } = font;\n\n const src = webFont\n ? `src: url(${webFont.url}) format('${webFont.format}');`\n : '';\n\n const style = `\n @font-face {\n font-family: '${fontFamily}';\n font-style: normal;\n font-weight: 400;\n mso-font-alt: '${fallbackFontFamily}';\n ${src}\n }`;\n\n return style;\n}\n"],"mappings":";;AAEA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAID,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;AACD;AA0GD,MAAaA,eAA0B;CACrC,oBAAoB;CACpB,YAAY;CACZ,SAAS;EACP,KAAK;EACL,QAAQ;CAC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