forked from haltersweb/Accessibility
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstar-rating.html
More file actions
100 lines (99 loc) · 6.2 KB
/
star-rating.html
File metadata and controls
100 lines (99 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Accessible Star Rating Options</title>
<link rel="stylesheet" href="css/normalization.css" />
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/star-rating-radio.css">
<link rel="stylesheet" href="css/star-rating-aria.css">
</head>
<body>
<div class="container">
<a href="#main" class="skip-link">Skip to main content</a>
<div class="page-wrapper" id="main" role="main" tabindex="-1">
<h1>Accessible Star Rating Options</h1>
<p><a href="http://haltersweb.github.io/Accessibility/">View the full library of accessibility solutions.</a></p>
<h2>Control</h2>
<form action="">
<fieldset>
<legend><span class="legend">How would you rate your appetizer?</span></legend>
<input type="radio" name="control" aria-label="1 star" />
<input type="radio" name="control" aria-label="2 stars" />
<input type="radio" name="control" aria-label="3 stars" />
<input type="radio" name="control" aria-label="4 stars" />
<input type="radio" name="control" aria-label="5 stars" />
</fieldset>
</form>
<h2>Option 1: Radio Buttons</h2>
<form action="" id="radioRating">
<fieldset class="rating-set">
<legend><span class="legend">How would you rate your meal?</span></legend>
<div class="star-group">
<input type="radio" name="rating" id="rate_1" class="radio-rating rate-1" aria-label="1 star" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" role="presentation" focusable="false" class="svg-star">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
<input type="radio" name="rating" id="rate_2" class="radio-rating rate-2" aria-label="2 stars" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" role="presentation" focusable="false" class="svg-star">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
<input type="radio" name="rating" id="rate_3" class="radio-rating rate-3" aria-label="3 stars" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" role="presentation" focusable="false" class="svg-star">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
<input type="radio" name="rating" id="rate_4" class="radio-rating rate-4" aria-label="4 stars" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" role="presentation" focusable="false" class="svg-star">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
<input type="radio" name="rating" id="rate_5" class="radio-rating rate-5" aria-label="5 stars" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" role="presentation" focusable="false" class="svg-star">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
</div>
</fieldset>
</form>
<h2>Option 2: ARIA Solution</h2>
<form action="" id="ariaRating">
<p id="ratingLegend" class="legend">How would you rate your dessert?</p>
<div class="star-group" role="radiogroup" aria-labelledby="ratingLegend">
<div class="star-button" role="radio" aria-label="1 star" aria-checked="false" tabindex="0">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" focusable="false">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
</div>
<div class="star-button" role="radio" aria-label="2 stars" aria-checked="false" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" focusable="false">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
</div>
<div class="star-button" role="radio" aria-label="3 stars" aria-checked="false" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" focusable="false">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
</div>
<div class="star-button" role="radio" aria-label="4 stars" aria-checked="false" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" focusable="false">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
</div>
<div class="star-button" role="radio" aria-label="5 stars" aria-checked="false" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 275" focusable="false">
<polygon xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#000000" stroke-width="15" points="150,25 179,111 269,111 197,165 223,251 150,200 77,251 103,165 31,111 121,111"/>
</svg>
</div>
</div>
</form>
</div>
<div class="overlay"></div>
<div class="block-screen"></div>
<div aria-live="polite" class="screen-reader-text"></div>
<div role="alert" class="screen-reader-text"></div>
</div>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/namespacing.js"></script>
<script type="text/javascript" src="js/accessibility-helpers.js"></script>
<script type="text/javascript" src="js/star-rating.js"></script>
</body>
</html>