Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

fix(ui/components/left_panel): use links for accessibility #43

Merged
merged 1 commit into from
Sep 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions src/modules/ui/components/left_panel/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const listStyle = {
...baseFonts,
};

const listStyleType = {
listStyleType: 'none',
'padding-left': 0,
};

const kindStyle = {
fontSize: 15,
padding: '10px 0px',
Expand Down Expand Up @@ -37,10 +42,8 @@ class Stories extends React.Component {

renderStory(story) {
const { selectedStory } = this.props;
const style = { ...storyStyle };
const style = { display: 'block', ...storyStyle };
const props = {
key: story,
style,
onClick: this.fireOnStory.bind(this, story),
};

Expand All @@ -49,49 +52,49 @@ class Stories extends React.Component {
}

return (
<div {...props}>
{story}
</div>
<li key={story}>
<a style={style} onClick={props.onClick}>{story}</a>
</li>
);
}

renderKind({ kind, stories }) {
const { selectedKind } = this.props;
const style = { ...kindStyle };
const style = { display: 'block', ...kindStyle };
const onClick = this.fireOnKind.bind(this, kind);

if (kind === selectedKind) {
style.fontWeight = 'bold';
return (
<div key={kind}>
<div
style={style}
onClick={this.fireOnKind.bind(this, kind)}
>
<li key={kind}>
<a style={style} onClick={onClick}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should <a href title="{Open ${kind}}" style={ be better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll add them now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a PR but we need to verify whether improve accessibility before merging
#44

{kind}
</div>
</a>
<div>
{stories.map(this.renderStory)}
<ul style={listStyleType}>
{stories.map(this.renderStory)}
</ul>
</div>
</div>
</li>
);
}

return (
<div
key={kind}
style={style}
onClick={this.fireOnKind.bind(this, kind, null)}
>
{kind}
</div>
<li key={kind}>
<a style={style} onClick={onClick}>
{kind}
</a>
</li>
);
}

render() {
const { stories } = this.props;
return (
<div style={listStyle}>
{stories.map(this.renderKind)}
<ul style={listStyleType}>
{stories.map(this.renderKind)}
</ul>
</div>
);
}
Expand Down