component-status.stories.mjs (4629B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ 4 5 import { 6 LitElement, 7 html, 8 css, 9 } from "chrome://global/content/vendor/lit.all.mjs"; 10 import componentsData from "./components.json"; 11 12 /* DS styles */ 13 import dsTokensTable from "toolkit/themes/shared/design-system/storybook/tokens-table.css"; 14 15 export default { 16 title: "Docs/Component Statuses", 17 parameters: { 18 options: { showPanel: false }, 19 docs: { source: { state: "closed" } }, 20 }, 21 }; 22 23 /** 24 * A component that displays the UI Widget Reusable Library components. 25 * 26 * Features: 27 * - Lists all reusable UI components from toolkit/content/widgets 28 * - Provides direct links to: 29 * - Individual component 30 * - Component source code in SearchFox 31 * - Related Bugzilla ticket 32 * - Shows implementation progress status for each component 33 * 34 * @see {@link https://bugzilla.mozilla.org/show_bug.cgi?id=1795301} Main tracking bug 35 */ 36 class ComponentStatusList extends LitElement { 37 static properties = { 38 _components: { state: true }, 39 }; 40 41 static styles = css` 42 tr td:first-of-type { 43 color-scheme: unset; 44 } 45 46 tr td { 47 border-bottom-color: var(--border-color); 48 } 49 50 /* the button look */ 51 a { 52 display: inline-flex; 53 align-items: center; 54 justify-content: center; 55 padding: var(--space-xsmall) var(--space-small); 56 border: var(--border-width) solid var(--border-color); 57 border-radius: var(--border-radius-small); 58 background: var(--button-background-color); 59 color: var(--link-color); /* prevent visited purple */ 60 text-decoration: none; 61 line-height: 1; 62 min-inline-size: 0; 63 cursor: pointer; 64 } 65 66 /* hover/active */ 67 a:hover { 68 background: var(--button-background-color-hover); 69 } 70 71 /* arrow only on external buttons */ 72 a[target="_blank"]::after { 73 content: "↗" !important; /* wins over any earlier content:none */ 74 margin-inline-start: var(--space-small); 75 font-size: var(--font-size-small); 76 line-height: 1; 77 opacity: 0.8; 78 } 79 `; 80 81 constructor() { 82 super(); 83 84 this._components = Array.isArray(componentsData?.items) 85 ? componentsData.items 86 : []; 87 } 88 89 render() { 90 return html` 91 <link rel="stylesheet" href=${dsTokensTable} /> 92 <header> 93 <h1>Component Statuses</h1> 94 <p> 95 Tracking 96 <a 97 href="https://bugzilla.mozilla.org/show_bug.cgi?id=1795301" 98 target="_blank" 99 rel="noreferrer" 100 >reusable components</a 101 > 102 from 103 <code>toolkit/content/widgets</code>. 104 </p> 105 </header> 106 <div class="table-wrapper">${this._renderTable()}</div> 107 `; 108 } 109 110 /******** Helpers *********/ 111 // Get story Id href 112 _storyHrefFromId(storyId) { 113 return storyId ? `/?path=/story/${storyId}` : "#"; 114 } 115 116 _renderLinkGroup(it) { 117 const storyHref = this._storyHrefFromId(it.storyId); 118 const links = [["Story", storyHref, { top: true }]]; 119 if (it.sourceUrl) { 120 links.push(["Source", it.sourceUrl, { top: false }]); 121 } 122 const bugUrl = it.bugUrl; 123 if (bugUrl && /bugzilla\.mozilla\.org/.test(bugUrl)) { 124 links.push(["Bugzilla", bugUrl, { top: false }]); 125 } 126 127 return html` 128 ${links.map( 129 ([label, href, opts = {}]) => html` 130 <a 131 href=${href} 132 rel="noreferrer" 133 target=${opts.top ? "_top" : "_blank"} 134 > 135 ${label} 136 </a> 137 ` 138 )} 139 `; 140 } 141 142 _renderTable() { 143 return html` 144 <table class="token-table"> 145 <thead> 146 <tr> 147 <th>Component</th> 148 <th>Status</th> 149 <th>Links</th> 150 </tr> 151 </thead> 152 <tbody> 153 ${this._components.map( 154 it => html` 155 <tr> 156 <td> 157 <a 158 href=${this._storyHrefFromId(it.storyId)} 159 target="_top" 160 rel="noreferrer" 161 > 162 ${it.component} 163 </a> 164 </td> 165 <td>${it.status ?? "unknown"}</td> 166 <td>${this._renderLinkGroup(it)}</td> 167 </tr> 168 ` 169 )} 170 </tbody> 171 </table> 172 `; 173 } 174 } 175 176 customElements.define("component-status-list", ComponentStatusList); 177 178 export const Default = () => { 179 return html`<component-status-list></component-status-list>`; 180 };