Skip to content

Commit

Permalink
Merge pull request #54 from YusukeHirao/hotfix/a11y/icon-wrapper
Browse files Browse the repository at this point in the history
アイコン名のキャメルケース表記を単語間に空白を加えて可読性を改善
  • Loading branch information
takanorip authored May 2, 2024
2 parents b95fc5c + 52d37ba commit f197e03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
5 changes: 1 addition & 4 deletions src/components/react/IconList/IconWrapper.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
line-height: var(--text-body-sm-line);
color: var(--color-text-sub);
text-align: center;
word-wrap: normal;
}

.copy {
Expand All @@ -36,7 +37,3 @@
.wrapper:hover .copy {
opacity: 1;
}

.word {
display: inline-block;
}
16 changes: 4 additions & 12 deletions src/components/react/IconList/IconWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,19 @@ const convertToIconComponentName = (iconName: string) => {
return `import { ${iconName} } from '@ubie/ubie-icons'`;
};

const splitUpperCase = (str: string) => {
return str.split(/(?=[A-Z])/);
};

const IconWrapper: FC<Props> = ({ children, index }) => {
const name = iconNames[index];

if (!name) return null;

const humanReadableName = name.split(/(?=[A-Z])/).join(' ');

return (
<div className={styles.wrapper}>
<div className={styles.icon} aria-label={`アイコン ${name}`} role="img">
<div className={styles.icon} aria-label={`アイコン ${humanReadableName}`} role="img">
{children}
</div>
<p className={styles.name}>
{splitUpperCase(name).map((str, index) => (
<span className={styles.word} key={index}>
{str}
</span>
))}
</p>
<p className={styles.name}>{humanReadableName}</p>
<CopyButton label="React" text={convertToIconComponentName(name)} className={styles.copy} />
</div>
);
Expand Down

0 comments on commit f197e03

Please sign in to comment.