Skip to content

Commit

Permalink
[UPDATE] added story name to aria label
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilbhatt committed Oct 9, 2022
1 parent a8616ff commit 0052f48
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
Binary file added app/assets/images/contributors/nikhil_bhatt.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions client/app/components/Story/StoryActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type Actions = {

export type Props = {
actions: Actions,
storyName: string,
hasStory?: boolean,
dark?: boolean,
};
Expand Down Expand Up @@ -111,16 +112,17 @@ const displayNonLink = (

const titleItem = (item: string) => item.charAt(0).toUpperCase() + item.slice(1);

const tooltipElement = (item: string, actions: Actions, dark: ?boolean) => {
const tooltipElement = (item: string, actions: Actions, storyName: string, dark: ?boolean) => {
const {
link, dataMethod, dataConfirm, name, onClick,
} = actions[item];
const ariaLabel = `${name} ${storyName}`
return (
<a
href={link}
data-method={dataMethod}
data-confirm={dataConfirm}
aria-label={name}
aria-label={ariaLabel}
onClick={
onClick
? (e: SyntheticEvent<HTMLInputElement>) => onClick(e, link)
Expand All @@ -135,12 +137,13 @@ const tooltipElement = (item: string, actions: Actions, dark: ?boolean) => {
const displayLink = (
actions: Actions,
item: string,
storyName: string,
hasStory: ?boolean,
dark: ?boolean,
) => (
<div key={item} className={`storyActions${titleItem(item)}`}>
<Tooltip
element={tooltipElement(item, actions, dark)}
element={tooltipElement(item, actions, storyName, dark)}
text={actions[item].name}
right={!!hasStory}
/>
Expand All @@ -150,17 +153,18 @@ const displayLink = (
const displayItem = (
actions: Actions,
item: string,
storyName: string,
hasStory: ?boolean,
dark: ?boolean,
) => {
if (item === VIEWERS || item === VISIBLE || item === SHARE_LINK_INFO) {
return displayNonLink(actions, item, hasStory, dark);
}
return displayLink(actions, item, hasStory, dark);
return displayLink(actions, item, storyName, hasStory, dark);
};

export const StoryActions = (props: Props): Node => {
const { actions, hasStory, dark } = props;
const { actions, hasStory, dark, storyName } = props;
return (
<div className={css.actions}>
{[
Expand All @@ -174,7 +178,7 @@ export const StoryActions = (props: Props): Node => {
VISIBLE,
VIEWERS,
SHARE_LINK_INFO,
].map((item: string) => (actions[item] ? displayItem(actions, item, hasStory, dark) : null))}
].map((item: string) => (actions[item] ? displayItem(actions, item, storyName, hasStory, dark) : null))}
</div>
);
};
10 changes: 6 additions & 4 deletions client/app/components/Story/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ const renderHeader = (
{draft && <StoryDraft draft={draft} />}
<StoryName name={name} link={link} onClick={onClick} />
</div>
{condensed && actions && <StoryActions actions={actions} hasStory />}
{condensed && actions && <StoryActions actions={actions} hasStory storyName={name} />}
</div>
</div>
);

const renderInfo = (
name: string,
storyBy: ?StoryByProps,
storyType: ?string,
actions: ?Actions,
Expand All @@ -61,7 +62,7 @@ const renderInfo = (
<StoryBy author={storyBy.author} avatar={storyBy.avatar} />
<div className={css.infoRight}>
<div className={css.storyType}>{storyType}</div>
{actions && <StoryActions actions={actions} hasStory />}
{actions && <StoryActions actions={actions} hasStory storyName={name} />}
</div>
</div>
);
Expand All @@ -88,6 +89,7 @@ const renderMedicationBody = ({
);

const renderFooter = (
name: string,
categories: ?(Category[]),
moods: ?(Mood[]),
storyBy: ?StoryByProps,
Expand All @@ -97,7 +99,7 @@ const renderFooter = (
<div className={css.footer}>
{categories && <StoryCategories categories={categories} />}
{moods && <StoryMoods moods={moods} />}
{renderInfo(storyBy, storyType, actions)}
{renderInfo(name, storyBy, storyType, actions)}
</div>
);

Expand All @@ -122,7 +124,7 @@ export const Story = ({
{date && <StoryDate date={date} />}
{body && <div className={css.body}>{Utils.renderContent(body)}</div>}
{medicationBody && renderMedicationBody(medicationBody)}
{renderFooter(categories, moods, storyBy, storyType, actions)}
{renderFooter(name, categories, moods, storyBy, storyType, actions)}
</div>
);
};
1 change: 1 addition & 0 deletions client/app/widgets/Comments/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const Comments = ({ comments, formProps }: Props): Node => {
commentByAdmin,
)}
hasStory
storyName={comment}
/>
</div>
</article>
Expand Down
9 changes: 9 additions & 0 deletions doc/pages/blurbs.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,5 +682,14 @@
"link_name": "manishsharma.ml",
"link": "https://manishsharma.ml",
"social": "globe"
},
{
"name": "Nikhil Bhatt",
"image": "/assets/contributors/nikhil_bhatt.jpg",
"profile": "Techie, who loves to solve the real world problems using code. Currently, I'm working as a Full stack developer in Ruby on Rails and React",
"location": "Bengaluru, India",
"link_name": "nikhilbhatt",
"link": "https://github.com/nikhilbhatt",
"social": "github"
}
]

0 comments on commit 0052f48

Please sign in to comment.