Skip to content

Commit

Permalink
Adding support for the ARIA role attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanKingston authored and bodil committed May 28, 2019
1 parent d0b4955 commit 1051565
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/stdweb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use typed_html::output::stdweb::Stdweb;

fn main() {
let mut doc = html!(
<div>
<div role="main">
<h1>"Hello Kitty"</h1>
<p>
"She is not a "<em><a href="https://en.wikipedia.org/wiki/Cat">"cat"</a></em>
Expand Down
1 change: 1 addition & 0 deletions macros/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub fn global_attrs(span: Span) -> StringyMap<Ident, TokenStream> {
insert("hidden", "crate::types::Bool");
insert("is", "String");
insert("lang", "crate::types::LanguageTag");
insert("role", "crate::types::Role");
insert("style", "String");
insert("tabindex", "isize");
insert("title", "String");
Expand Down
140 changes: 140 additions & 0 deletions typed-html/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,146 @@ pub enum ReferrerPolicy {
UnsafeUrl,
}

#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
pub enum Role {
#[strum(to_string = "any")]
Any,
#[strum(to_string = "alert")]
Alert,
#[strum(to_string = "alertdialog")]
AlertDialog,
#[strum(to_string = "application")]
Application,
#[strum(to_string = "article")]
Article,
#[strum(to_string = "banner")]
Banner,
#[strum(to_string = "checkbox")]
Checkbox,
#[strum(to_string = "cell")]
Cell,
#[strum(to_string = "columnheader")]
ColumnHeader,
#[strum(to_string = "combobox")]
ComboBox,
#[strum(to_string = "complementary")]
Complementary,
#[strum(to_string = "contentinfo")]
ContentInfo,
#[strum(to_string = "definition")]
Definition,
#[strum(to_string = "dialog")]
Dialog,
#[strum(to_string = "directory")]
Directory,
#[strum(to_string = "document")]
Document,
#[strum(to_string = "feed")]
Feed,
#[strum(to_string = "figure")]
Figure,
#[strum(to_string = "form")]
Form,
#[strum(to_string = "grid")]
Grid,
#[strum(to_string = "gridcell")]
GridCell,
#[strum(to_string = "group")]
Group,
#[strum(to_string = "heading")]
Heading,
#[strum(to_string = "img")]
Image,
#[strum(to_string = "link")]
Link,
#[strum(to_string = "list")]
List,
#[strum(to_string = "listbox")]
ListBox,
#[strum(to_string = "listitem")]
ListItem,
#[strum(to_string = "log")]
Log,
#[strum(to_string = "main")]
Main,
#[strum(to_string = "marquee")]
Marquee,
#[strum(to_string = "math")]
Math,
#[strum(to_string = "menu")]
Menu,
#[strum(to_string = "menubar")]
MenuBar,
#[strum(to_string = "menuitem")]
MenuItem,
#[strum(to_string = "menuitemcheckbox")]
MenuItemCheckbox,
#[strum(to_string = "menuitemradio")]
MenuItemRadio,
#[strum(to_string = "navigation")]
Navigation,
#[strum(to_string = "none")]
None,
#[strum(to_string = "note")]
Note,
#[strum(to_string = "option")]
Option,
#[strum(to_string = "presentation")]
Presentation,
#[strum(to_string = "progressbar")]
ProgressBar,
#[strum(to_string = "radio")]
Radio,
#[strum(to_string = "radiogroup")]
RadioGroup,
#[strum(to_string = "region")]
Region,
#[strum(to_string = "row")]
Row,
#[strum(to_string = "rowgroup")]
RowGroup,
#[strum(to_string = "rowheader")]
RowHeader,
#[strum(to_string = "scrollbar")]
ScrollBar,
#[strum(to_string = "search")]
Search,
#[strum(to_string = "searchbox")]
SearchBox,
#[strum(to_string = "separator")]
Separator,
#[strum(to_string = "slider")]
Slider,
#[strum(to_string = "spinbutton")]
SpinButton,
#[strum(to_string = "status")]
Status,
#[strum(to_string = "switch")]
Switch,
#[strum(to_string = "tab")]
Tab,
#[strum(to_string = "table")]
Table,
#[strum(to_string = "tablist")]
TabList,
#[strum(to_string = "tabpanel")]
TabPanel,
#[strum(to_string = "term")]
Term,
#[strum(to_string = "textbox")]
TextBox,
#[strum(to_string = "timer")]
Timer,
#[strum(to_string = "toolbar")]
ToolBar,
#[strum(to_string = "tooltip")]
ToolTip,
#[strum(to_string = "tree")]
Tree,
#[strum(to_string = "treegrid")]
TreeGrid,
}

#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
pub enum Sandbox {
#[strum(to_string = "allow-forms")]
Expand Down

0 comments on commit 1051565

Please sign in to comment.