Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update with fully Right to Left support for rtl languages #747

Merged
merged 8 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
12 changes: 10 additions & 2 deletions packages/emoji-mart/src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export default class Navigation extends PureComponent {
let selectedCategoryIndex = null

return (
<nav id="nav" class="padding" data-position={this.props.position}>
<nav
id="nav"
class="padding"
data-position={this.props.position}
dir={this.props.dir}
EtienneLem marked this conversation as resolved.
Show resolved Hide resolved
>
<div class="flex relative">
{this.categories.map((category, i) => {
const title = category.name || I18n.categories[category.id]
Expand Down Expand Up @@ -87,7 +92,10 @@ export default class Navigation extends PureComponent {
style={{
width: `${100 / this.categories.length}%`,
opacity: selectedCategoryIndex == null ? 0 : 1,
transform: `translateX(${selectedCategoryIndex * 100}%)`,
transform:
this.props.dir === 'rtl'
EtienneLem marked this conversation as resolved.
Show resolved Hide resolved
? `scaleX(-1) translateX(${selectedCategoryIndex * 100}%)`
: `translateX(${selectedCategoryIndex * 100}%)`,
}}
></div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/emoji-mart/src/components/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ export default class Picker extends Component {
ref={this.refs.navigation}
icons={this.props.icons}
theme={this.state.theme}
dir={this.dir}
unfocused={!!this.state.searchResults}
position={this.props.navPosition}
onClick={this.handleCategoryClick}
Expand Down Expand Up @@ -819,8 +820,6 @@ export default class Picker extends Component {
<div>
<div class="spacer"></div>
<div class="flex flex-middle">
{renderSkinTone && this.dir == 'rtl' && this.renderSkinToneButton()}

<div class="search relative flex-grow">
<input
type="search"
Expand All @@ -846,7 +845,7 @@ export default class Picker extends Component {
)}
</div>

{renderSkinTone && this.dir == 'ltr' && this.renderSkinToneButton()}
{renderSkinTone && this.renderSkinToneButton()}
</div>
</div>
)
Expand Down Expand Up @@ -1103,6 +1102,7 @@ export default class Picker extends Component {
<section
id="root"
class="flex flex-column"
dir={this.dir}
data-emoji-set={this.props.set}
data-theme={this.state.theme}
data-menu={this.state.showSkins ? '' : undefined}
Expand Down
26 changes: 26 additions & 0 deletions packages/emoji-mart/src/components/Picker/PickerStyles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ a {

.spacer { height: 10px }

[dir="rtl"] .scroll {
padding-left: 0;
padding-right: var(--padding);
}

.scroll {
overflow: auto;
overflow-x: hidden;
Expand Down Expand Up @@ -190,6 +195,22 @@ a {
backdrop-filter: blur(4px);
}

[dir="rtl"] .search {
input[type="search"] {
padding: 10px 2.2em 10px 2em;
}

.loupe {
right: .7em;
left: auto;
}

.delete {
left: .7em;
right: auto;
}
}

.search {
z-index: 2;
position: relative;
Expand Down Expand Up @@ -273,6 +294,11 @@ button {
height: var(--category-icon-size);
}

&[dir="rtl"] .bar {
right: 0;
left: auto;
}

.bar {
position: absolute;
bottom: -12px; left: 0;
Expand Down