Skip to content

Commit dd9c541

Browse files
DanielRyanSmithDanielRyanSmith
andauthored
Annotate survey features (#1406)
* annotate the survey features * adjust feature check * update appearance based on feedback * fix feature ordering and query * changes suggested by @jcscottiii --------- Co-authored-by: DanielRyanSmith <danielrsmith@google.com>
1 parent f68970f commit dd9c541

File tree

4 files changed

+115
-16
lines changed

4 files changed

+115
-16
lines changed

frontend/src/static/js/components/test/webstatus-stats-missing-one-impl-chart-panel.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe('WebstatusStatsMissingOneImplChartPanel', () => {
186186
it('renders missing one implementation features footer', async () => {
187187
apiClientStub.getMissingOneImplementationFeatures.resolves([
188188
{
189-
feature_id: 'css',
189+
feature_id: 'grid',
190190
},
191191
{
192192
feature_id: 'html',
@@ -232,7 +232,7 @@ describe('WebstatusStatsMissingOneImplChartPanel', () => {
232232
const expectedHeader = `
233233
<div slot="header" id="missing-one-implementation-list-header">
234234
Missing features on 2024-01-01 for Chrome:
235-
<a href="/?q=id%3Acss+OR+id%3Ahtml+OR+id%3Ajs+OR+id%3Abluetooth">4 features</a>
235+
<a href="/?q=id%3Agrid+OR+id%3Ahtml+OR+id%3Ajs+OR+id%3Abluetooth">4 features</a>
236236
</div>
237237
`;
238238
expect(header).dom.to.equal(expectedHeader);
@@ -246,10 +246,12 @@ describe('WebstatusStatsMissingOneImplChartPanel', () => {
246246
expect(rows.length).to.equal(10, 'should have 10 rows');
247247

248248
const firstRowCells = rows[0].querySelectorAll('td');
249-
expect(firstRowCells[0].textContent?.trim()).to.equal(
250-
'css',
251-
'first row ID',
252-
);
249+
const textContent = firstRowCells[0].textContent
250+
?.split('\n')
251+
.map(word => word.trim())
252+
.filter(word => word.length > 0)
253+
.join(' ');
254+
expect(textContent).to.equal('grid TOP CSS', 'first row ID');
253255
});
254256

255257
it('renders empty features footer', async () => {

frontend/src/static/js/components/utils.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
import {html, TemplateResult} from 'lit';
18+
import {
19+
TOP_CSS_INTEROP_ISSUES,
20+
TOP_HTML_INTEROP_ISSUES,
21+
} from '../utils/constants.js';
22+
1723
export const DRAWER_WIDTH_PX = 288;
1824

1925
// Determine if the browser looks like the user is on a mobile device.
@@ -34,3 +40,47 @@ export const IS_MOBILE = (() => {
3440

3541
return width <= NARROW_WINDOW_MAX_WIDTH || width === 0;
3642
})();
43+
44+
function getTopSurveyIdentifierTemplate(
45+
surveyName: string,
46+
url: string,
47+
): TemplateResult | undefined {
48+
return html`<sl-tag
49+
size="small"
50+
variant="${surveyName === 'CSS' ? 'success' : 'primary'}"
51+
pill
52+
>
53+
<div
54+
class="survey-result"
55+
title="This feature was listed as a top interoperability pain point in the recent State of ${surveyName} survey."
56+
>
57+
<span class="survey-result-span">
58+
<a href="${url}" target="_blank">TOP ${surveyName}</a>
59+
</span>
60+
</div>
61+
</sl-tag>`;
62+
}
63+
64+
export function getTopCssIdentifierTemplate(
65+
featureId: string | undefined,
66+
): TemplateResult | undefined {
67+
if (featureId && TOP_CSS_INTEROP_ISSUES.includes(featureId)) {
68+
return getTopSurveyIdentifierTemplate(
69+
'CSS',
70+
'https://2024.stateofhtml.com/',
71+
);
72+
}
73+
return undefined;
74+
}
75+
76+
export function getTopHtmlIdentifierTemplate(
77+
featureId: string | undefined,
78+
): TemplateResult | undefined {
79+
if (featureId && TOP_HTML_INTEROP_ISSUES.includes(featureId)) {
80+
return getTopSurveyIdentifierTemplate(
81+
'HTML',
82+
'https://2024.stateofhtml.com/',
83+
);
84+
}
85+
return undefined;
86+
}

frontend/src/static/js/components/webstatus-stats-missing-one-impl-chart-panel.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ import {
3131
import {ChartSelectPointEvent} from './webstatus-gchart.js';
3232
import {customElement, state} from 'lit/decorators.js';
3333
import {formatOverviewPageUrl} from '../utils/urls.js';
34+
import {
35+
getTopCssIdentifierTemplate,
36+
getTopHtmlIdentifierTemplate,
37+
} from './utils.js';
3438

3539
@customElement('webstatus-stats-missing-one-impl-chart-panel')
3640
export class WebstatusStatsMissingOneImplChartPanel extends WebstatusLineChartPanel {
@@ -63,8 +67,15 @@ export class WebstatusStatsMissingOneImplChartPanel extends WebstatusLineChartPa
6367
overflow-x: auto;
6468
white-space: nowrap;
6569
}
66-
.missing-feature-id-link {
67-
padding-right: 1em;
70+
.missing-feature-id {
71+
padding: 0.5em 1em 0 0;
72+
}
73+
.survey-result,
74+
.survey-result:hover,
75+
.survey-result a {
76+
font-size: 10px;
77+
text-decoration: none;
78+
cursor: help;
6879
}
6980
`,
7081
];
@@ -240,12 +251,22 @@ export class WebstatusStatsMissingOneImplChartPanel extends WebstatusLineChartPa
240251
for (let j = 0; j < numCols; j++) {
241252
const featureIndex = j * 10 + i;
242253
if (featureIndex < this.missingFeaturesList.length) {
243-
const feature_id = this.missingFeaturesList[featureIndex].feature_id;
254+
const featureId = this.missingFeaturesList[featureIndex].feature_id;
255+
const extraIdentifiers: TemplateResult[] = [];
256+
const cssIdentifier = getTopCssIdentifierTemplate(featureId);
257+
if (cssIdentifier) {
258+
extraIdentifiers.push(cssIdentifier);
259+
}
260+
const htmlIdentifier = getTopHtmlIdentifierTemplate(featureId);
261+
if (htmlIdentifier) {
262+
extraIdentifiers.push(htmlIdentifier);
263+
}
244264
cells.push(
245265
html` <td>
246-
<a href="/features/${feature_id}" class="missing-feature-id-link"
247-
>${feature_id}</a
248-
>
266+
<div class="missing-feature-id">
267+
<a href="/features/${featureId}">${featureId}</a>
268+
${extraIdentifiers}
269+
</div>
249270
</td>`,
250271
);
251272
} else {

frontend/src/static/js/utils/constants.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,34 @@ export interface SavedSearch {
5959
description?: string;
6060
}
6161

62+
export const TOP_CSS_INTEROP_ISSUES: string[] = [
63+
'anchor-positioning',
64+
'container-queries',
65+
'has',
66+
'nesting',
67+
'view-transitions',
68+
'subgrid',
69+
'grid',
70+
'scrollbar-gutter',
71+
'scrollbar-width',
72+
'scrollbar-color',
73+
'scroll-driven-animations',
74+
'scope',
75+
];
76+
77+
export const TOP_HTML_INTEROP_ISSUES: string[] = [
78+
'popover',
79+
'anchor-positioning',
80+
'cross-document-view-transitions',
81+
'dialog',
82+
'datalist',
83+
'customized-built-in-elements',
84+
'file-system-access',
85+
'scroll-driven-animations',
86+
'notifications',
87+
'web-bluetooth',
88+
];
89+
6290
export const DEFAULT_GLOBAL_SAVED_SEARCHES: GlobalSavedSearch[] = [
6391
{
6492
name: 'Baseline 2025',
@@ -92,17 +120,15 @@ export const DEFAULT_GLOBAL_SAVED_SEARCHES: GlobalSavedSearch[] = [
92120
},
93121
{
94122
name: 'Top CSS Interop issues',
95-
query:
96-
'id:anchor-positioning OR id:container-queries OR id:has OR id:nesting OR id:view-transitions OR id:subgrid OR id:grid OR name:scrollbar OR id:scroll-driven-animations OR id:scope',
123+
query: `id:${TOP_CSS_INTEROP_ISSUES.join(' OR id:')}`,
97124
description:
98125
"This list reflects the top 10 interoperability pain points identified by developers in the State of CSS 2024 survey. We have also included their implementation status across Baseline browsers. You will notice that in some cases the items are already Baseline features, but may not have have been Baseline for long enough for developers to use with their target audience's browser support requirements. Since some voted-on pain points involve multiple web features, the list extends beyond 10 individual items for clarity and comprehensive coverage.",
99126
is_ordered: true,
100127
override_num_param: 25,
101128
},
102129
{
103130
name: 'Top HTML Interop issues',
104-
query:
105-
'id:popover OR id:anchor-positioning OR id:cross-document-view-transitions OR id:dialog OR id:datalist OR id:customized-built-in-elements OR id:file-system-access OR id:scroll-driven-animations OR id:notifications OR id:web-bluetooth',
131+
query: `id:${TOP_HTML_INTEROP_ISSUES.join(' OR id:')}`,
106132
description:
107133
"This list reflects the top 10 interoperability pain points identified by developers in the State of HTML 2024 survey. We have also included their implementation status across Baseline browsers. You will notice that in some cases the items are already Baseline features, but may not have have been Baseline for long enough for developers to use with their target audience's browser support requirements.",
108134
is_ordered: true,

0 commit comments

Comments
 (0)