|
1 | 1 | import { poppinsFontSVG } from '../constants'; |
2 | | -import { Theme, themes } from '../theme/awesome-card'; |
| 2 | +import { getThemeStyles, Theme } from '../theme/awesome-card'; |
3 | 3 |
|
4 | 4 | interface Props { |
5 | 5 | quote: string; |
6 | 6 | author: string; |
7 | | - color: Theme; |
| 7 | + color: Theme | null; |
8 | 8 | border: boolean; |
9 | 9 | } |
10 | 10 |
|
11 | 11 | export const renderHorizontal = ({ quote, author, color, border }: Props) => { |
| 12 | + const themeStyles = getThemeStyles(color, border); // gets css styling for specific theme |
| 13 | + |
12 | 14 | const renderedSVG = ` |
13 | 15 | <svg width="600" height="auto" fill="none" xmlns="http://www.w3.org/2000/svg"> |
14 | 16 | <foreignObject width="100%" height="100%"> |
15 | | - <div xmlns="http://www.w3.org/1999/xhtml"> |
16 | | - ${poppinsFontSVG} |
17 | | -
|
18 | | - <style> |
19 | | - * { |
20 | | - padding: 0; |
21 | | - margin: 0; |
22 | | - box-sizing: border-box; |
23 | | - } |
24 | | - .container { |
25 | | - font-family: Poppins, Arial, Helvetica, sans-serif; |
26 | | - padding: 20px; |
27 | | - width: 600px; |
28 | | - border: ${border ? "3px solid #"+themes.default.symbol : "1px solid rgba(0, 0, 0, 0.2)"}; |
29 | | - border-radius: 10px; |
30 | | - } |
31 | | - .container h3 { |
32 | | - font-size: 19px; |
33 | | - margin-bottom: 5px; |
34 | | - font-weight: 500; |
35 | | - font-style: oblique; |
36 | | - } |
37 | | - .container h3::before { |
38 | | - content: open-quote; |
39 | | - font-size: 25px; |
40 | | - } |
41 | | - .container h3::after { |
42 | | - content: close-quote; |
43 | | - vertical-align: sub; |
44 | | - font-size: 25px; |
45 | | - } |
46 | | - .container p { |
47 | | - font-style: italic; |
48 | | - padding: 5px; |
49 | | - text-align: right; |
50 | | - } |
51 | | - |
52 | | - /* Default light theme */ |
53 | | - .container { |
54 | | - background-color: #${themes.default.background}; |
55 | | - } |
56 | | - .container h3 { |
57 | | - color: #${themes.default.quote}; |
58 | | - } |
59 | | - .container h3::before, .container h3::after { |
60 | | - color: #${themes.default.symbol}; |
61 | | - } |
62 | | - .container p { |
63 | | - color: #${themes.default.author}; |
64 | | - } |
65 | | - |
66 | | - /* Default dark theme - iff dark mode detected in system settings, overriding default light theme */ |
67 | | - @media (prefers-color-scheme: dark) { |
68 | | - .container { |
69 | | - background-color: #${themes.defaultDarkModeSupport.background}; |
70 | | - border: ${border ? "3px solid #"+themes.defaultDarkModeSupport.symbol : "1px solid rgba(0, 0, 0, 0.2)"}; |
71 | | - } |
72 | | - .container h3 { |
73 | | - color: #${themes.defaultDarkModeSupport.quote}; |
74 | | - } |
75 | | - .container h3::before, .container h3::after { |
76 | | - color: #${themes.defaultDarkModeSupport.symbol}; |
77 | | - } |
78 | | - .container p { |
79 | | - color: #${themes.defaultDarkModeSupport.author}; |
80 | | - } |
81 | | - } |
82 | | - |
83 | | - /* Default light/dark mode theme override for any custom theme */ |
84 | | - ${JSON.stringify(color) !== JSON.stringify(themes.default) && |
85 | | - JSON.stringify(color) !== JSON.stringify(themes.defaultDarkModeSupport) ? |
86 | | - ` .container { |
87 | | - background-color: #${color.background}; |
88 | | - border: ${border ? "3px solid #"+color.symbol : "1px solid rgba(0, 0, 0, 0.2)"}; |
89 | | - } |
90 | | - .container h3 { |
91 | | - color: #${color.quote}; |
92 | | - } |
93 | | - .container h3::before, .container h3::after { |
94 | | - color: #${color.symbol}; |
95 | | - } |
96 | | - .container p { |
97 | | - color: #${color.author}; |
98 | | - } |
99 | | - ` : ''} |
100 | | - </style> |
101 | | -
|
102 | | - <div class="container"> |
103 | | - <h3> ${quote}</h3> |
104 | | - <p>- ${author}</p> |
105 | | - </div> |
| 17 | + <div xmlns="http://www.w3.org/1999/xhtml"> |
| 18 | + ${poppinsFontSVG} |
| 19 | + <style> |
| 20 | + * { |
| 21 | + padding: 0; |
| 22 | + margin: 0; |
| 23 | + box-sizing: border-box; |
| 24 | + } |
| 25 | + .container { |
| 26 | + font-family: Poppins, Arial, Helvetica, sans-serif; |
| 27 | + padding: 20px; |
| 28 | + width: 600px; |
| 29 | + border-radius: 10px; |
| 30 | + } |
| 31 | + .container h3 { |
| 32 | + font-size: 19px; |
| 33 | + margin-bottom: 5px; |
| 34 | + font-weight: 500; |
| 35 | + font-style: oblique; |
| 36 | + } |
| 37 | + .container h3::before { |
| 38 | + content: open-quote; |
| 39 | + font-size: 25px; |
| 40 | + } |
| 41 | + .container h3::after { |
| 42 | + content: close-quote; |
| 43 | + vertical-align: sub; |
| 44 | + font-size: 25px; |
| 45 | + } |
| 46 | + .container p { |
| 47 | + font-style: italic; |
| 48 | + padding: 5px; |
| 49 | + text-align: right; |
| 50 | + } |
| 51 | + ${themeStyles} |
| 52 | + </style> |
| 53 | + <div class="container"> |
| 54 | + <h3>${quote}</h3> |
| 55 | + <p>- ${author}</p> |
106 | 56 | </div> |
| 57 | + </div> |
107 | 58 | </foreignObject> |
108 | 59 | </svg> |
109 | | -`; |
| 60 | + `; |
110 | 61 |
|
111 | 62 | return renderedSVG; |
112 | 63 | }; |
0 commit comments