Who is this Sarah person?
Design?
I want it to "just work"
interface ButtonProperties {
label?: text;
iconType?: string;
iconAltText?: string;
}
w(Button, {
iconType: 'search'
});
<button>
<svg role="img">
<use xlink:href="#search"></use>
</svg>
</button>
Yes, this looks right. I am done here.
interface ButtonProperties {
label?: string;
icon?: {
type: string;
altText: string;
};
}
Fine, I will smash my keys until this error goes away
w(Button, {
icon: {
type: 'search',
altText: 'search'
}
});
<button>
<svg role="img" aria-labelledby="search-title">
<title id="search-title">search</title>
<use xlink:href="#search"></use>
</svg>
</button>
Docs? What are docs?
Email Subject: Where do I find icon types?
Body: For some reason icon.type: 'magnifying-glass'
isn't working. What do I do?
interface ButtonProperties {
label?: string;
icon?: {
type: string;
altText: string;
};
}
w(Button, {
label: 'Search',
icon: {
type: 'magnifying-glass',
altText: 'search'
}
});
<button>
Search
<svg role="img" aria-labelledby="search-title">
<title id="search-title">search</title>
<use xlink:href="#magnifying-glass"></use>
</svg>
</button>
enum IconType {
plus,
arrow,
search
};
interface PresentationIcon {
type: IconType;
presentation: true;
}
interface ContentIcon {
type: IconType;
altText: string;
}
interface ButtonProperties {
label?: string;
icon?: PresentationIcon | ContentIcon;
}
Hmmm... one of these looks right
<button>
Search
<svg aria-hidden="true">
<use xlink:href="#search"></use>
</svg>
</button>
I also want it to do
[insert 10 extra features, and a pony]
First let's talk about aria
...
<button>
?type
aria-expanded
aria-haspopup
aria-pressed
interface ButtonProperties {
aria?: { [key: string]: string; };
popup?: boolean;
pressed?: boolean;
type?: 'submit' | 'reset' | 'button' | 'menu';
}
<button>
element
interface PonyButtonProperties extends ButtonProperties {
ponyDance?: boolean;
}
class PonyButton extends Button<PonyButtonProperties> {
renderIcon() {
...
}
}
Create an interface for an optionally hidden label on a text input
<span class="required">*</span>
aria-label
is ignored by all common translation services
interface TextInputProperties {
label: string | HTMLElement;
labelHidden?: boolean;
}
@codingchaos • #TSConf #EscapeTheOffice