mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-30 07:38:12 +00:00
Refactor MySeaRecordsPage to use AmharicDatePicker and update styles for better UX
This commit is contained in:
@@ -31,7 +31,7 @@ import {
|
|||||||
IconTrash,
|
IconTrash,
|
||||||
} from '@tabler/icons-react';
|
} from '@tabler/icons-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { AdvancedTable, notify, useServerTable, type AdvancedColumn } from '@ema-platform/ui';
|
import { AdvancedTable, AmharicDatePicker, notify, useServerTable, type AdvancedColumn } from '@ema-platform/ui';
|
||||||
import {
|
import {
|
||||||
extractErrorMessage,
|
extractErrorMessage,
|
||||||
uploadDocument,
|
uploadDocument,
|
||||||
@@ -400,23 +400,23 @@ function SeaServiceTab() {
|
|||||||
onChange={(e) => setForm({ ...form, rank: e.target.value })}
|
onChange={(e) => setForm({ ...form, rank: e.target.value })}
|
||||||
/>
|
/>
|
||||||
<Group grow>
|
<Group grow>
|
||||||
<TextInput
|
<AmharicDatePicker
|
||||||
type="date"
|
|
||||||
label="Engagement date"
|
label="Engagement date"
|
||||||
required
|
required
|
||||||
value={form.engagementDate}
|
value={form.engagementDate}
|
||||||
onChange={(e) =>
|
onChange={(val) =>
|
||||||
setForm({ ...form, engagementDate: e.target.value })
|
setForm({ ...form, engagementDate: val })
|
||||||
}
|
}
|
||||||
|
dateFormat="date"
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<AmharicDatePicker
|
||||||
type="date"
|
|
||||||
label="Discharge date"
|
label="Discharge date"
|
||||||
required
|
required
|
||||||
value={form.dischargeDate}
|
value={form.dischargeDate}
|
||||||
onChange={(e) =>
|
onChange={(val) =>
|
||||||
setForm({ ...form, dischargeDate: e.target.value })
|
setForm({ ...form, dischargeDate: val })
|
||||||
}
|
}
|
||||||
|
dateFormat="date"
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<Textarea
|
<Textarea
|
||||||
@@ -684,19 +684,19 @@ function MedicalTab() {
|
|||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group grow>
|
<Group grow>
|
||||||
<TextInput
|
<AmharicDatePicker
|
||||||
type="date"
|
|
||||||
label="Issue date"
|
label="Issue date"
|
||||||
required
|
required
|
||||||
value={form.issueDate}
|
value={form.issueDate}
|
||||||
onChange={(e) => setForm({ ...form, issueDate: e.target.value })}
|
onChange={(val) => setForm({ ...form, issueDate: val })}
|
||||||
|
dateFormat="date"
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<AmharicDatePicker
|
||||||
type="date"
|
|
||||||
label="Expiry date"
|
label="Expiry date"
|
||||||
required
|
required
|
||||||
value={form.expiryDate}
|
value={form.expiryDate}
|
||||||
onChange={(e) => setForm({ ...form, expiryDate: e.target.value })}
|
onChange={(val) => setForm({ ...form, expiryDate: val })}
|
||||||
|
dateFormat="date"
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
no border/box affordance and a hardcoded blue chevron. */
|
no border/box affordance and a hardcoded blue chevron. */
|
||||||
.amharic-daypicker {
|
.amharic-daypicker {
|
||||||
--rdp-accent-color: var(--mantine-primary-color-filled);
|
--rdp-accent-color: var(--mantine-primary-color-filled);
|
||||||
--rdp-day-height: 44px;
|
--rdp-day-height: 36px;
|
||||||
--rdp-day-width: 44px;
|
--rdp-day-width: 36px;
|
||||||
--rdp-day_button-height: 42px;
|
--rdp-day_button-height: 34px;
|
||||||
--rdp-day_button-width: 42px;
|
--rdp-day_button-width: 34px;
|
||||||
--rdp-weekday-padding: 0.5rem 0;
|
--rdp-weekday-padding: 0.25rem 0;
|
||||||
--rdp-nav-height: 2.75rem;
|
--rdp-nav-height: 2.25rem;
|
||||||
--rdp-nav_button-width: 2.75rem;
|
--rdp-nav_button-width: 2rem;
|
||||||
--rdp-nav_button-height: 2.75rem;
|
--rdp-nav_button-height: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Backoffice loads Tailwind's preflight after the package stylesheet. That
|
/* Backoffice loads Tailwind's preflight after the package stylesheet. That
|
||||||
@@ -170,3 +170,16 @@
|
|||||||
border-color: var(--mantine-primary-color-filled);
|
border-color: var(--mantine-primary-color-filled);
|
||||||
color: var(--mantine-color-white);
|
color: var(--mantine-color-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure no scrollbar appears on the datepicker popover dropdown */
|
||||||
|
.amharic-daypicker-dropdown {
|
||||||
|
overflow: hidden !important;
|
||||||
|
scrollbar-width: none !important;
|
||||||
|
-ms-overflow-style: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.amharic-daypicker-dropdown::-webkit-scrollbar {
|
||||||
|
display: none !important;
|
||||||
|
width: 0 !important;
|
||||||
|
height: 0 !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export function AmharicDatePicker({
|
|||||||
? calendarType === 'EN'
|
? calendarType === 'EN'
|
||||||
? selected.toLocaleDateString('en-US', {
|
? selected.toLocaleDateString('en-US', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'long',
|
month: 'short',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
})
|
})
|
||||||
: toAmharicDisplay(selected)
|
: toAmharicDisplay(selected)
|
||||||
@@ -228,6 +228,8 @@ export function AmharicDatePicker({
|
|||||||
trapFocus
|
trapFocus
|
||||||
withArrow
|
withArrow
|
||||||
withinPortal
|
withinPortal
|
||||||
|
shadow="md"
|
||||||
|
radius="md"
|
||||||
// The field lives inside a Modal's scrollable body while the dropdown is
|
// The field lives inside a Modal's scrollable body while the dropdown is
|
||||||
// portaled to <body> — a different scroll container than its reference.
|
// portaled to <body> — a different scroll container than its reference.
|
||||||
// The default `absolute` strategy sums offsets across that scroll chain
|
// The default `absolute` strategy sums offsets across that scroll chain
|
||||||
@@ -255,37 +257,46 @@ export function AmharicDatePicker({
|
|||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
onClick={() => !disabled && toggle()}
|
onClick={() => !disabled && toggle()}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
|
styles={{
|
||||||
|
input: {
|
||||||
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
||||||
|
},
|
||||||
|
}}
|
||||||
leftSection={
|
leftSection={
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="light"
|
variant="subtle"
|
||||||
size="compact-xs"
|
size="compact-xs"
|
||||||
tabIndex={0}
|
tabIndex={-1}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setCalendarType((prev) => (prev === 'EN' ? 'AMH' : 'EN'));
|
setCalendarType((prev) => (prev === 'EN' ? 'AMH' : 'EN'));
|
||||||
}}
|
}}
|
||||||
aria-label={t('common.switchCalendar')}
|
aria-label={t('common.switchCalendar')}
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
paddingLeft: 6,
|
||||||
|
paddingRight: 6,
|
||||||
|
fontWeight: 600,
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{calendarType}
|
{calendarType}
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
leftSectionWidth="calc(4.375rem * var(--mantine-scale))"
|
leftSectionWidth="3.25rem"
|
||||||
rightSection={
|
rightSection={
|
||||||
<ActionIcon size="md" variant="transparent" disabled={disabled} onClick={() => toggle()}>
|
<ActionIcon size="sm" variant="transparent" disabled={disabled} onClick={() => toggle()}>
|
||||||
<IconCalendarEvent size={20} />
|
<IconCalendarEvent size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
|
|
||||||
{/* Inside a Modal there may not be room below the field for the full
|
{/* Inside a Modal the dropdown is portaled out of the modal body so it positions nicely. */}
|
||||||
calendar + time input + action row — scroll the dropdown itself
|
<Popover.Dropdown className="amharic-daypicker-dropdown" p="sm" style={{ overflow: 'hidden' }}>
|
||||||
rather than relying on the page (which doesn't scroll while a
|
|
||||||
Modal is open) or the Modal body (the dropdown is portaled out of
|
|
||||||
it, so its scroll never reaches this). */}
|
|
||||||
<Popover.Dropdown p="md" mah="70dvh" style={{ overflowY: 'auto' }}>
|
|
||||||
{calendarType === 'AMH' ? (
|
{calendarType === 'AMH' ? (
|
||||||
<EthiopicDayPicker
|
<EthiopicDayPicker
|
||||||
className="amharic-daypicker"
|
className="amharic-daypicker"
|
||||||
|
|||||||
Reference in New Issue
Block a user