Compare commits
2 Commits
v3.0.0-dev
...
v3.0.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 05a04ec922 | |||
| 3b91fad590 |
@@ -2,6 +2,8 @@
|
||||
import { fade } from 'svelte/transition';
|
||||
import type { HTMLInputAttributes } from 'svelte/elements';
|
||||
|
||||
import { IconChevronRightFilled } from '@tabler/icons-svelte';
|
||||
|
||||
interface Props extends HTMLInputAttributes {
|
||||
value?: string;
|
||||
label?: string;
|
||||
@@ -9,6 +11,7 @@
|
||||
type?: 'text' | 'password' | 'email' | 'number' | 'search' | 'tel' | 'url';
|
||||
error?: string;
|
||||
uppercase?: boolean;
|
||||
onsubmit?: (val: string) => void | Promise<void>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
@@ -19,10 +22,18 @@
|
||||
type = 'text',
|
||||
error = '',
|
||||
uppercase = false,
|
||||
onsubmit,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
let isFocussed = $state(false);
|
||||
|
||||
const handleSubmit = (e: Event) => {
|
||||
e.preventDefault();
|
||||
if (onsubmit && value) {
|
||||
onsubmit(value);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="input-wrapper" class:focussed={isFocussed} class:has-error={!!error}>
|
||||
@@ -30,16 +41,30 @@
|
||||
<label for="adaptive-input">{label}</label>
|
||||
{/if}
|
||||
|
||||
<input
|
||||
id="adaptive-input"
|
||||
class:all-caps={uppercase}
|
||||
{type}
|
||||
{placeholder}
|
||||
bind:value
|
||||
onfocus={() => (isFocussed = true)}
|
||||
onblur={() => (isFocussed = false)}
|
||||
{...rest}
|
||||
/>
|
||||
<form onsubmit={handleSubmit} class="input-container">
|
||||
<input
|
||||
id="adaptive-input"
|
||||
class:all-caps={uppercase}
|
||||
{type}
|
||||
{placeholder}
|
||||
bind:value
|
||||
onfocus={() => (isFocussed = true)}
|
||||
onblur={() => (isFocussed = false)}
|
||||
{...rest}
|
||||
/>
|
||||
|
||||
{#if onsubmit}
|
||||
<button
|
||||
type="submit"
|
||||
class="submit-icon"
|
||||
transition:fade
|
||||
disabled={!value}
|
||||
aria-label="Submit"
|
||||
>
|
||||
<IconChevronRightFilled />
|
||||
</button>
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
{#if error}
|
||||
<span class="error-message" transition:fade>{error}</span>
|
||||
@@ -50,11 +75,22 @@
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 0.4rem;
|
||||
width: 100%;
|
||||
font-family: 'URW Gothic', sans-serif;
|
||||
}
|
||||
|
||||
.input-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
background-color: var(--color-title);
|
||||
border-radius: 5000px;
|
||||
transition: all 0.2s;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 400;
|
||||
@@ -62,17 +98,46 @@
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
min-height: 40px;
|
||||
padding: 0 16px;
|
||||
background-color: var(--color-title);
|
||||
border: 2px solid transparent;
|
||||
border-radius: 20px;
|
||||
height: 100%;
|
||||
line-height: normal;
|
||||
padding: 0 48px;
|
||||
border: none;
|
||||
color: var(--color-bg-dark);
|
||||
font-size: 1.2rem;
|
||||
transition: all 0.2s ease-in-out;
|
||||
outline: none;
|
||||
text-align: center;
|
||||
box-shadow: var(--shadow-std);
|
||||
}
|
||||
|
||||
.submit-icon {
|
||||
position: absolute;
|
||||
background: transparent;
|
||||
right: 0;
|
||||
border: none;
|
||||
color: var(--color-bg-dark);
|
||||
cursor: pointer;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0.75;
|
||||
transition:
|
||||
opacity 0.2s,
|
||||
transform 0.2s;
|
||||
}
|
||||
|
||||
.submit-icon:hover:not(:disabled) {
|
||||
opacity: 1;
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
.submit-icon:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.all-caps {
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="train-service">
|
||||
<div class="train-service" class:isExpanded>
|
||||
<button class="summary" onclick={toggleExpand} type="button" aria-expanded={isExpanded}>
|
||||
{#if loadingDetails}
|
||||
<div class="loading-state"><div class="loading-spinner"></div></div>
|
||||
@@ -147,7 +147,15 @@
|
||||
{/if}
|
||||
{#if details.pis}
|
||||
<div class="pis-detail">
|
||||
{details.pis.code}
|
||||
<span class="pis-code">PIS: {details.Pis.code}</span>
|
||||
{#if details.Pis.skip?.skip > 0}
|
||||
<span class="pis-skip">
|
||||
(skip {details.Pis.skip.position === 'head' ? 'first' : 'last'}
|
||||
{details.Pis.skip.skip}
|
||||
{details.Pis.skip.skip === 1 ? 'stop' : 'stops'}
|
||||
)
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -173,8 +181,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
{#each details.locations as loc}
|
||||
<tbody class="location-group">
|
||||
|
||||
<tbody class="location-group">
|
||||
<tr class:pass-loc={loc.r === 'PASS'} class:can-loc={loc.can}>
|
||||
<td class="tpl-cell" class:tpl-stop={loc.r != 'PASS'}>
|
||||
{loc.t}
|
||||
@@ -202,18 +209,17 @@
|
||||
{/if}
|
||||
</tr>
|
||||
{#if loc.act && getRelevantActivities(loc.act).length > 0}
|
||||
<tr class="activity-row">
|
||||
<td colspan="7">
|
||||
<div class="activity-container">
|
||||
{#each getRelevantActivities(loc.act) as note}
|
||||
<span class="activity-tag">{note}</span>
|
||||
{/each}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="activity-row">
|
||||
<td colspan="7">
|
||||
<div class="activity-container">
|
||||
{#each getRelevantActivities(loc.act) as note}
|
||||
<span class="activity-tag">{note}</span>
|
||||
{/each}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
</tbody>{/each}
|
||||
</tbody>{/each}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -241,10 +247,18 @@
|
||||
filter: brightness(1.2);
|
||||
}
|
||||
|
||||
.train-service:active .arrow {
|
||||
filter: brightness(0.2);
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.train-service:hover {
|
||||
.train-service:not(.isExpanded):hover {
|
||||
filter: brightness(1.2);
|
||||
}
|
||||
|
||||
.summary:hover .arrow {
|
||||
filter: brightness(0.2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -299,7 +313,7 @@
|
||||
padding: 0;
|
||||
margin: 0 0 0 auto;
|
||||
height: 25px;
|
||||
transition: all 0.9s;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.expanded {
|
||||
@@ -310,6 +324,29 @@
|
||||
color: red;
|
||||
}
|
||||
|
||||
/*
|
||||
PIS Data
|
||||
*/
|
||||
.pis-detail {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
padding: 8px 0;
|
||||
width: 100%;
|
||||
}
|
||||
.pis-code {
|
||||
font-weight: 600;
|
||||
font-size: 1.1rem;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.pis-skip {
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.75;
|
||||
font-style: oblique;
|
||||
}
|
||||
|
||||
/*
|
||||
Box Extention
|
||||
*/
|
||||
@@ -408,9 +445,9 @@
|
||||
|
||||
.activity-tag {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.tpl-cell {
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
let headcode = $state('');
|
||||
|
||||
function handleSearch(e: SubmitEvent) {
|
||||
e.preventDefault();
|
||||
function handleSearch(headcode: string) {
|
||||
if (!headcode.trim()) return;
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
@@ -18,10 +17,14 @@
|
||||
</script>
|
||||
|
||||
<BaseCard header={'Search Train & PIS'}>
|
||||
<form onsubmit={handleSearch} class="card-content">
|
||||
<Textbox placeholder="Enter Headcode" bind:value={headcode} maxLength={4} />
|
||||
<Button type="submit" disabled={!headcode}>Search</Button>
|
||||
</form>
|
||||
<div class="card-content">
|
||||
<Textbox
|
||||
placeholder="Enter Headcode"
|
||||
bind:value={headcode}
|
||||
maxLength={4}
|
||||
onsubmit={handleSearch}
|
||||
/>
|
||||
</div>
|
||||
</BaseCard>
|
||||
|
||||
<style>
|
||||
@@ -29,7 +32,7 @@
|
||||
text-align: center;
|
||||
width: 90%;
|
||||
margin: auto;
|
||||
padding: 10px 0 0 0;
|
||||
padding: 10px 0 0.5rem 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
|
||||
Reference in New Issue
Block a user