Skip to content

Commit 42d8730

Browse files
committed
styling the top story.
1 parent 2f8905d commit 42d8730

File tree

1 file changed

+19
-160
lines changed

1 file changed

+19
-160
lines changed

src/ui/dictionary/dictionaryView.svelte

Lines changed: 19 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
<script lang="ts">
22
import type APIManager from "src/apiManager";
33
import type { DictionaryWord, HNItem } from "src/integrations/types";
4-
import type LocalDictionaryBuilder from "src/localDictionaryBuilder";
5-
4+
65
import PhoneticComponent from "./phoneticComponent.svelte";
76
import MeaningComponent from "./meaningComponent.svelte";
87
import ErrorComponent from "./errorComponent.svelte";
98
import OriginComponent from "./originComponent.svelte";
109
import t from "src/l10n/helpers";
1110
1211
export let manager: APIManager;
13-
export let localDictionary: LocalDictionaryBuilder;
1412
1513
export let query: string = "";
1614
let promise: Promise<DictionaryWord>;
@@ -46,189 +44,50 @@
4644
</script>
4745

4846
<div class="main">
49-
<div class="searchbox">
50-
<button class="dictionary-button" on:click={languageModal}
51-
><i class="languageIcon" alt="Language" /></button
52-
>
53-
<input
54-
type="text"
55-
spellcheck="true"
56-
placeholder={t("Enter a word")}
57-
bind:value={query}
58-
on:keydown={handleKeyDown}
59-
/>
60-
<button class="dictionary-button" on:click={search}
61-
><i class="searchIcon" alt="Search" /></button
62-
>
63-
</div>
64-
<br />
65-
<button class="dictionary-button" on:click={fetchTopHN}
66-
>Fetch TopHN</button
67-
>
6847
{#if promiseTopHN}
6948
{#await promiseTopHN}
7049
<div class="center" />
7150
{:then data}
7251
<div class="results">
7352
<div class="container">
74-
<p>{ data.title }</p>
75-
<p>{ data.url }</p>
53+
<a href="{ data.url }" target="_blank" class="hn-link">{ data.title }</a>
54+
<br />
55+
<p class="hn-read">
56+
<a href="{ data.url }" target="_blank">Read more →</a>
57+
</p>
7658
</div>
7759
</div>
7860
{:catch error}
7961
<ErrorComponent {error} />
8062
{/await}
8163
{/if}
82-
83-
{#if promise && query.trim()}
84-
{#await promise}
85-
<div class="center">
86-
<div class="spinner" />
87-
</div>
88-
{:then data}
89-
{#if query === data.word}
90-
<div class="results">
91-
{#if data.phonetics.first().text}
92-
<div class="container">
93-
<h3>{t("Pronunciation")}</h3>
94-
{#each data.phonetics as { text, audio }}
95-
<PhoneticComponent {audio} {text} />
96-
{/each}
97-
</div>
98-
{/if}
99-
<div class="container">
100-
<h3>{t("Meanings")}</h3>
101-
{#each data.meanings as { definitions, partOfSpeech }}
102-
<MeaningComponent word={data.word} {partOfSpeech} {definitions} />
103-
{/each}
104-
</div>
105-
{#if data.origin}
106-
<div class="container">
107-
<h3>{t("Origin")}</h3>
108-
<OriginComponent {data}/>
109-
</div>
110-
{/if}
111-
</div>
112-
<span
113-
class="nn"
114-
on:click={async () => await localDictionary.newNote(data)}
115-
>{t("New Note")}</span
116-
>
117-
{/if}
118-
{:catch error}
119-
<ErrorComponent {error} />
120-
{/await}
121-
{/if}
12264
</div>
12365

12466
<style lang="scss">
67+
.hn-link {
68+
font-size: 1em;
69+
text-decoration: none;
70+
}
71+
72+
.hn-read {
73+
font-size: 0.75em;
74+
text-align: right;
75+
margin-top: 0.5em;
76+
}
77+
12578
.results {
12679
display: flex;
12780
flex-wrap: wrap;
12881
}
12982
130-
.nn {
131-
color: var(--text-faint);
132-
transition: 0.2s;
133-
width: 100%;
134-
display: inline-block;
135-
text-align: center;
136-
margin-top: 1.5rem;
137-
font-size: 1em;
138-
&:hover {
139-
color: var(--text);
140-
}
141-
}
142-
14383
.container {
14484
max-width: 30vw;
14585
width: 100%;
14686
margin: auto;
14787
background-color: var(--background-primary-alt);
148-
padding-left: 0.5rem;
149-
padding-right: 0.5rem;
150-
padding-top: 0.3rem;
151-
padding-bottom: 0.3rem;
152-
margin-top: 0.5rem;
88+
padding: 1rem 1rem;
89+
margin-top: 0.2rem;
15390
border-radius: 0.3rem;
154-
> h3 {
155-
margin-top: 0.3rem;
156-
margin-bottom: 0.3rem;
157-
font-weight: normal;
158-
}
159-
}
160-
161-
.searchbox {
162-
margin-top: 0.1rem;
163-
display: flex;
164-
165-
> input {
166-
width: 100%;
167-
margin-right: 0.8rem;
168-
margin-left: 0.8rem;
169-
}
170-
}
171-
172-
.dictionary-button {
173-
margin-right: 0px;
174-
}
175-
176-
.searchIcon {
177-
box-sizing: border-box;
178-
position: relative;
179-
display: block;
180-
transform: scale(var(--ggs, 1));
181-
width: 16px;
182-
height: 16px;
183-
border: 2px solid;
184-
border-radius: 100%;
185-
margin-left: -4px;
186-
margin-top: -4px;
187-
}
188-
.searchIcon::after {
189-
content: "";
190-
display: block;
191-
box-sizing: border-box;
192-
position: absolute;
193-
border-radius: 3px;
194-
width: 2px;
195-
height: 8px;
196-
background: currentColor;
197-
transform: rotate(-45deg);
198-
top: 10px;
199-
left: 12px;
200-
}
201-
202-
.languageIcon,
203-
.languageIcon::after,
204-
.languageIcon::before {
205-
display: block;
206-
box-sizing: border-box;
207-
height: 18px;
208-
border: 2px solid;
209-
}
210-
.languageIcon {
211-
position: relative;
212-
transform: scale(var(--ggs, 1));
213-
width: 18px;
214-
border-radius: 22px;
215-
}
216-
.languageIcon::after,
217-
.languageIcon::before {
218-
content: "";
219-
position: absolute;
220-
width: 8px;
221-
border-radius: 100%;
222-
top: -2px;
223-
left: 3px;
224-
}
225-
.languageIcon::after {
226-
width: 24px;
227-
height: 20px;
228-
border: 2px solid transparent;
229-
border-bottom: 2px solid;
230-
top: -11px;
231-
left: -5px;
23291
}
23392
23493
.center {

0 commit comments

Comments
 (0)