Skip to content

Commit

Permalink
fix: use ellipsis for tags text in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed Jun 1, 2021
1 parent 19a85a1 commit af3bed8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
38 changes: 22 additions & 16 deletions app/assets/javascripts/components/AutocompleteTagInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,28 @@ export const AutocompleteTagInput: FunctionalComponent<Props> = ({
onBlur={closeOnBlur}
tabIndex={tabIndex}
>
<Icon type="hashtag" className="color-neutral mr-2" />
{tag.title
.split(new RegExp(`(${searchQuery})`, 'gi'))
.map((substring, index) => (
<span
key={index}
className={
substring.toLowerCase() ===
searchQuery.toLowerCase()
? 'font-bold whitespace-pre-wrap'
: 'whitespace-pre-wrap'
}
>
{substring}
</span>
))}
<Icon type="hashtag" className="color-neutral mr-2 min-h-5 min-w-5" />
<span className="whitespace-nowrap overflow-hidden overflow-ellipsis">
{searchQuery === '' ? (
tag.title
) : (
tag.title
.split(new RegExp(`(${searchQuery})`, 'gi'))
.map((substring, index) => (
<span
key={index}
className={`${
substring.toLowerCase() ===
searchQuery.toLowerCase()
? 'font-bold whitespace-pre-wrap'
: 'whitespace-pre-wrap '
}`}
>
{substring}
</span>
))
)}
</span>
</button>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/NoteTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const NoteTags = observer(({ application, appState }: Props) => {
<div
ref={tagsContainerRef}
className={`absolute bg-default h-9 flex flex-wrap pl-1 -ml-1 ${
tagsContainerExpanded ? '' : 'overflow-y-hidden'
tagsContainerExpanded ? '' : 'overflow-hidden'
}`}
style={{
maxWidth: tagsContainerMaxWidth,
Expand Down Expand Up @@ -188,7 +188,7 @@ const NoteTags = observer(({ application, appState }: Props) => {
type="hashtag"
className="sn-icon--small color-neutral mr-1"
/>
<span className="whitespace-nowrap overflow-y-hidden overflow-ellipsis">
<span className="whitespace-nowrap overflow-hidden overflow-ellipsis">
{tag.title}
</span>
</button>
Expand Down
12 changes: 10 additions & 2 deletions app/assets/stylesheets/_sn.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@
max-width: 20rem;
}

.min-w-5 {
min-width: 1.25rem;
}

.h-1px {
height: 1px;
}
Expand Down Expand Up @@ -208,6 +212,10 @@
max-height: 30rem;
}

.min-h-5 {
min-height: 1.25rem;
}

.fixed {
position: fixed;
}
Expand All @@ -220,8 +228,8 @@
overflow: auto;
}

.overflow-y-hidden {
overflow-y: hidden;
.overflow-hidden {
overflow: hidden;
}

.overflow-ellipsis {
Expand Down

0 comments on commit af3bed8

Please sign in to comment.