Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feed Example: Convert images to inline SVG #2729

Merged
merged 9 commits into from
Jul 24, 2023
Merged
35 changes: 35 additions & 0 deletions content/patterns/feed/examples/css/feedDisplay.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,38 @@ body {
padding: 10px;
width: 100%;
}

.restaurant-rating svg g {
color: #ffde00;
}

.restaurant-rating svg .star {
stroke-width: 2px;
stroke: #f8951d;
fill-opacity: 0;
}

.restaurant-rating[data-rating-value="1"] svg .star-1 .star {
fill: currentcolor;
fill-opacity: 1;
}

.restaurant-rating[data-rating-value="2"] svg .star-2 .star {
fill: currentcolor;
fill-opacity: 1;
}

.restaurant-rating[data-rating-value="3"] svg .star-3 .star {
fill: currentcolor;
fill-opacity: 1;
}

.restaurant-rating[data-rating-value="4"] svg .star-4 .star {
fill: currentcolor;
fill-opacity: 1;
}

.restaurant-rating[data-rating-value="5"] svg .star-5 .star {
fill: currentcolor;
fill-opacity: 1;
}
31 changes: 24 additions & 7 deletions content/patterns/feed/examples/js/feedDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,31 @@ aria.FeedDisplay.prototype.renderItemData = function (itemData) {
itemContent +=
'<div class="restaurant-rating" id="' +
ratingID +
'">' +
'<img class="restaurant-star-img" ' +
'alt="' +
itemData.rating +
' stars" ' +
'src="imgs/rating-' +
'" data-rating-value="' +
itemData.rating +
'.png">' +
'">' +
'<svg role="none" xmlns="http://www.w3.org/2000/svg" viewBox="38 -5 100 48" width="90" height="25">' +
'<defs>' +
'<g id="star">' +
'<polygon points="2.0,13.4 11.7,20.5 8.0,31.1 17.7,24.8 27.4,31.9 23.7,20.5 33.4,13.4 21.4,13.4 17.7,2.0 14.0,13.4" />' +
'</g>' +
'</defs>' +
'<g aria-label="one star" class="star-1 star-2 star-3 star-4 star-5">' +
frozenzia marked this conversation as resolved.
Show resolved Hide resolved
'<use class="star" xlink:href="#star" x="0" y="0" />' +
'</g>' +
'<g aria-label="two stars" class="star-2 star-3 star-4 star-5">' +
'<use class="star" xlink:href="#star" x="35" y="0" />' +
'</g>' +
'<g aria-label="three stars" class="star-3 star-4 star-5">' +
'<use class="star" xlink:href="#star" x="70" y="0" />' +
'</g>' +
'<g aria-label="four stars" class="star-4 star-5">' +
'<use class="star" xlink:href="#star" x="105" y="0" />' +
'</g>' +
'<g aria-label="five stars" class="star-5">' +
'<use class="star" xlink:href="#star" x="140" y="0" />' +
'</g>' +
'</svg>' +
'</div>';
describedbyIDs.push(ratingID);
}
Expand Down
2 changes: 1 addition & 1 deletion test/tests/grid_data_grids.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ ariaTest(
}
}

// Test focus moves down
// Test focus moves up
await sendKeyToGridcell(
t,
gridSelector,
Expand Down
2 changes: 1 addition & 1 deletion test/tests/grid_layout_grids.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ ariaTest(
return document.activeElement;
});

// Test focus to last element in row using key chord CONTROL+HOME
// Test focus to first element in row using key chord CONTROL+HOME
await activeElement.sendKeys(Key.chord(Key.CONTROL, Key.HOME));
activeElement = await t.context.session.executeScript(() => {
return document.activeElement;
Expand Down
4 changes: 2 additions & 2 deletions test/tests/treegrid_treegrid-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,12 +722,12 @@ ariaTest('END moves focus', exampleFile, 'key-end', async (t) => {
'Sending END to first row should result on focus on last row'
);

// Send HOME to first gridcell
// Send END to first gridcell
await putFocusOnRow1Gridcell(t, 0);
await sendKeyToGridcellAndWait(t, 0, 0, Key.END);
t.true(
await checkFocusOnGridcell(t, 0, 2),
"Sending HOME to first row's first gridcell should move focus to first row's last gridcell"
"Sending END to first row's first gridcell should move focus to first row's last gridcell"
);
});

Expand Down