|
| 1 | +// Component Name |
| 2 | +export const componentName = 'TopBarToolName'; |
| 3 | + |
| 4 | +// TopBarToolName - React sandbox example |
| 5 | +export const componentTsx = /* javascript */ `import { TopBarToolName } from '@guardian/stand/TopBar'; |
| 6 | +
|
| 7 | +export const Component = () => { |
| 8 | + return ( |
| 9 | + <> |
| 10 | + <TopBarToolName |
| 11 | + name="Songwriter" |
| 12 | + favicon={{ type: 'letter', letter: 'S' }} |
| 13 | + subsection="Article" |
| 14 | + subsectionIcon="menu" |
| 15 | + /> |
| 16 | + </> |
| 17 | + ); |
| 18 | +}; |
| 19 | +`; |
| 20 | + |
| 21 | +// Toolname - Custom component - CSS example |
| 22 | +export const componentCss = /* css */ `@import "@guardian/stand/component/TopBar.css"; |
| 23 | + /* import the favicon styles */ |
| 24 | + @import '@guardian/stand/component/favicon.css'; |
| 25 | +
|
| 26 | + /* example setup of tool name */ |
| 27 | + .stand-topbar-toolname { |
| 28 | + display: var(--component-top-bar-tool-name-display); |
| 29 | + align-items: var(--component-top-bar-tool-name-align-items); |
| 30 | + gap: var(--component-top-bar-tool-name-gap); |
| 31 | + font: var(--component-top-bar-tool-name-typography-font); |
| 32 | + letter-spacing: var(--component-top-bar-tool-name-typography-letter-spacing); |
| 33 | + font-variation-settings: "wdth" var(--component-top-bar-tool-name-typography-font-width); |
| 34 | + } |
| 35 | +
|
| 36 | + .stand-topbar-toolname-divider { |
| 37 | + border-right: var(--component-top-bar-tool-name-divider-border); |
| 38 | + height: var(--component-top-bar-tool-name-divider-height); |
| 39 | + } |
| 40 | +
|
| 41 | + .stand-topbar-toolname-subsection { |
| 42 | + display: var(--component-top-bar-tool-name-display); |
| 43 | + align-items: var(--component-top-bar-tool-name-align-items); |
| 44 | + gap: var(--component-top-bar-tool-name-subsection-gap); |
| 45 | + font: var(--component-top-bar-tool-name-subsection-typography-font); |
| 46 | + letter-spacing: var(--component-top-bar-tool-name-subsection-typography-letter-spacing); |
| 47 | + font-variation-settings: "wdth" var(--component-top-bar-tool-name-subsection-typography-font-width) |
| 48 | + } |
| 49 | +
|
| 50 | + .stand-favicon { |
| 51 | + background-color: var(--component-favicon-color-background); |
| 52 | + display: var(--component-favicon-display); |
| 53 | + align-items: var(--component-favicon-align-items); |
| 54 | + justify-content: var(--component-favicon-justify-content); |
| 55 | + width: var(--component-favicon-size); |
| 56 | + height: var(--component-favicon-size); |
| 57 | + user-select: var(--component-favicon-user-select); |
| 58 | + color: var(--component-favicon-color-text); |
| 59 | + font: var(--component-favicon-typography-font); |
| 60 | + letter-spacing: var(--component-favicon-typography-letter-spacing); |
| 61 | + font-variation-settings: "wdth" var(--component-favicon-typography-font-width); |
| 62 | + } |
| 63 | +
|
| 64 | +`; |
| 65 | + |
| 66 | +export const componentHtml = /* html */ `<div class="container"> |
| 67 | + <div class="stand-topbar-toolname"> |
| 68 | + <div class="stand-favicon">S</div> |
| 69 | + <div>Songwriter</div> |
| 70 | + <div class="stand-topbar-toolname-divider"> </div> |
| 71 | + <div class="stand-topbar-toolname-subsection"> |
| 72 | + <div><svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#1f1f1f"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z"></path></svg></div> |
| 73 | + <div>Article</div> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | +</div>`; |
| 77 | + |
| 78 | +// Tool name - Custom component - JS example |
| 79 | +export const componentJs = /* javascript */ ` |
| 80 | + // for ts/js |
| 81 | + import { componentFavicon, componentTopBar, baseColors } from '@guardian/stand'; |
| 82 | +
|
| 83 | + const style = \` |
| 84 | + display: \${componentTopBar.ToolName.display}; |
| 85 | + align-items: \${componentTopBar.ToolName["align-items"]}; |
| 86 | + gap: \${componentTopBar.ToolName.gap}; |
| 87 | + font: \${componentTopBar.ToolName.typography.font}; |
| 88 | + letter-spacing: \${componentTopBar.ToolName.typography.letterSpacing}; |
| 89 | + font-variation-settings: "wdth" \${componentTopBar.ToolName.typography.fontWidth}; |
| 90 | + \`; |
| 91 | +
|
| 92 | + const dividerStyle = \` |
| 93 | + border-right: \${componentTopBar.ToolName.divider.border}; |
| 94 | + height: \${componentTopBar.ToolName.divider.height}; |
| 95 | + \`; |
| 96 | +
|
| 97 | + const subsectionStyle = \` |
| 98 | + display: \${componentTopBar.ToolName.display}; |
| 99 | + align-items: \${componentTopBar.ToolName["align-items"]}; |
| 100 | + gap: \${componentTopBar.ToolName.subsection.gap}; |
| 101 | + font: \${componentTopBar.ToolName.subsection.typography.font}; |
| 102 | + letter-spacing: \${componentTopBar.ToolName.subsection.typography.letterSpacing}; |
| 103 | + font-variation-settings: "wdth" \${componentTopBar.ToolName.subsection.typography.fontWidth}; |
| 104 | + \`; |
| 105 | +
|
| 106 | + const faviconStyle = \` |
| 107 | + background-color: \${componentFavicon.color.background}; |
| 108 | + display: \${componentFavicon.display}; |
| 109 | + align-items: \${componentFavicon["align-items"]}; |
| 110 | + justify-content: \${componentFavicon["justify-content"]}; |
| 111 | + width: \${componentFavicon.size}; |
| 112 | + height: \${componentFavicon.size}; |
| 113 | + user-select: \${componentFavicon["user-select"]}; |
| 114 | + color: \${componentFavicon.color.text}; |
| 115 | + font: \${componentFavicon.typography.font}; |
| 116 | + letter-spacing: \${componentFavicon.typography.letterSpacing}; |
| 117 | + font-variation-settings: "wdth" \${componentFavicon.typography.fontWidth}; |
| 118 | + \`; |
| 119 | +
|
| 120 | + // e.g. adding to DOM using vanilla JS styles |
| 121 | + document.getElementById("app").innerHTML = \` |
| 122 | +
|
| 123 | + <div class="container"> |
| 124 | + <div style="\${style}"> |
| 125 | + <div style="\${faviconStyle}>S</div> |
| 126 | + <div>Songwriter</div> |
| 127 | + <div style="\${dividerStyle}"> </div> |
| 128 | + <div style="\${subsectionStyle}"> |
| 129 | + <div><svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#1f1f1f"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z"></path></svg></div> |
| 130 | + <div>Article</div> |
| 131 | + </div> |
| 132 | + </div> |
| 133 | + </div> |
| 134 | +\`; |
| 135 | +`; |
0 commit comments