Skip to content

Commit

Permalink
added divider without modifying DOM using CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
nrakhay committed Mar 22, 2024
1 parent 2d3d1cb commit ad951f6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
34 changes: 15 additions & 19 deletions src/components/translator/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,25 +211,21 @@ const LangsDropdown = ({
const [code, name] = langs[j];
const valid = !validLang || validLang(code);
langElems.push(
<div>
<button
className={classNames('language-name', {
'variant-language-name': isVariant(code),
'text-muted': !valid,
})}
disabled={!valid}
key={code}
onClick={() => {
setLang(code);
document.body.click();
}}
tabIndex={0}
>
{name}
</button>

<div style={{ height: '0.5px', backgroundColor: 'gray', opacity: '30%' }} />
</div>,
<button
className={classNames('language-name', {
'variant-language-name': isVariant(code),
'text-muted': !valid,
})}
disabled={!valid}
key={code}
onClick={() => {
setLang(code);
document.body.click();
}}
tabIndex={0}
>
{name}
</button>,
);
}

Expand Down
13 changes: 12 additions & 1 deletion src/components/translator/translator.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ html[dir='rtl'] .copy-text-button {

.language-name {
display: block;
padding: 0;
overflow-x: hidden;
position: relative;
text-overflow: ellipsis;
Expand All @@ -53,6 +52,18 @@ html[dir='rtl'] .copy-text-button {
text-align: unset;
}

.language-name:after {
content: '';
position: absolute;
left: 0;
right: 0;
height: 0.5px;
width: 100%;
background-color: black;
opacity: 30%;
display: block;
}

html[dir='ltr'] .language-name {
padding-left: 0.5em;
}
Expand Down

0 comments on commit ad951f6

Please sign in to comment.