Skip to content

Commit

Permalink
Fix ellipsis and mark style (#242)
Browse files Browse the repository at this point in the history
`:global(…)` doesn't work on custom elements. Here's a workaround suggested in
sveltejs/svelte#2969 (comment)
  • Loading branch information
mpellerin42 authored Sep 12, 2022
1 parent 4e7f410 commit 008a054
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
5 changes: 0 additions & 5 deletions libs/search-widget/src/Widget.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
@import "common-style";

:global(mark) {
background-color: inherit;
font-weight: var(--font-weight-semi-bold);
}
3 changes: 3 additions & 0 deletions libs/search-widget/src/Widget.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import type { KBStates, Resource } from '@nuclia/core';
import { Observable } from 'rxjs';
import { setupSuggestionsAndPredictions, setupTriggerSearch } from './core/search-bar';
import globalCss from './_video-widget/_global.scss';
export let backend = 'https://nuclia.cloud/api';
export let widgetid = '';
Expand Down Expand Up @@ -126,6 +127,8 @@
};
</script>

<svelte:element this="style">{@html globalCss}</svelte:element>

<div class="nuclia-widget" {style} data-version="__NUCLIA_DEV_VERSION__">
{#if ready}
{#if type === 'input'}
Expand Down
2 changes: 2 additions & 0 deletions libs/search-widget/src/_video-widget/SearchBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { setLang } from '../core/i18n';
import SearchInput from '../widgets/search-input/SearchInput.svelte';
import { setupTriggerSearch } from '../core/search-bar';
import globalCss from './_global.scss';
export let backend = 'https://nuclia.cloud/api';
export let widgetid = '';
Expand Down Expand Up @@ -68,6 +69,7 @@
});
</script>

<svelte:element this="style">{@html globalCss}</svelte:element>
<div class="nuclia-widget" data-version="__NUCLIA_DEV_VERSION__">
{#if ready}
<SearchInput {placeholder} searchBarWidget={true} />
Expand Down
11 changes: 0 additions & 11 deletions libs/search-widget/src/_video-widget/SearchResults.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,3 @@
flex-direction: column;
gap: var(--rhythm-3);
}

:global(mark) {
background-color: inherit;
font-weight: var(--font-weight-semi-bold);
}

:global(.ellipsis) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
2 changes: 2 additions & 0 deletions libs/search-widget/src/_video-widget/SearchResults.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { _ } from '../core/i18n';
import LoadingDots from '../components/spinner/LoadingDots.svelte';
import VideoTile from './VideoTile.svelte';
import globalCss from './_global.scss';
const showResults = nucliaStore().triggerSearch.pipe(map(() => true));
const results = nucliaState().results;
Expand Down Expand Up @@ -43,6 +44,7 @@
});
</script>

<svelte:element this="style">{@html globalCss}</svelte:element>
<div class="nuclia-widget sw-video-results" data-version="__NUCLIA_DEV_VERSION__">
{#if $showResults}
{#if $hasSearchError}
Expand Down
10 changes: 10 additions & 0 deletions libs/search-widget/src/_video-widget/_global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mark {
background-color: inherit;
font-weight: var(--font-weight-semi-bold);
}

.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

0 comments on commit 008a054

Please sign in to comment.