Add one-tap hide control to home clock tile
Original task: #56 — Let users hide or show the home clock with one tap. Changes: - artifacts/teaboy-os/src/pages/home.tsx: Added a small dismiss "×" button overlay on the SortableClockTile. The button stops pointer propagation so it does not trigger drag or the existing long-press size toggle. It calls setHomeClockVisible(false) (now destructured from useHomeClockVisibility) to hide the tile in one tap. The button uses absolute positioning with `end-1` so it works in both LTR and RTL. It is always visible at large size and revealed on hover/focus at compact size to keep the tile clean. - artifacts/teaboy-os/src/locales/{en,ar}.json: Added `home.clockStyle.hideWidget` ("Hide clock" / "إخفاء الساعة") used as the button's aria-label and tooltip. Re-showing the clock is handled by the existing toggle in the clock style picker popover (already bilingual), so users can bring the clock back later. Hiding/showing keeps the persisted grid position. Notes / deviations: - Did not add a context-menu since long-press is already used for the size toggle on the same tile and would conflict. - Pre-existing TypeScript errors in unrelated files (admin.tsx, clock-style-picker.tsx codegen drift) are not addressed here.
This commit is contained in:
@@ -81,6 +81,7 @@
|
|||||||
"clockStyle": {
|
"clockStyle": {
|
||||||
"label": "نمط الساعة",
|
"label": "نمط الساعة",
|
||||||
"showWidget": "إظهار ساعة الحائط في الشاشة الرئيسية",
|
"showWidget": "إظهار ساعة الحائط في الشاشة الرئيسية",
|
||||||
|
"hideWidget": "إخفاء الساعة",
|
||||||
"hourFormat": {
|
"hourFormat": {
|
||||||
"label": "صيغة الساعة",
|
"label": "صيغة الساعة",
|
||||||
"h12": "12 ساعة (ص/م)",
|
"h12": "12 ساعة (ص/م)",
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
"clockStyle": {
|
"clockStyle": {
|
||||||
"label": "Clock style",
|
"label": "Clock style",
|
||||||
"showWidget": "Show wall clock on home screen",
|
"showWidget": "Show wall clock on home screen",
|
||||||
|
"hideWidget": "Hide clock",
|
||||||
"hourFormat": {
|
"hourFormat": {
|
||||||
"label": "Hour format",
|
"label": "Hour format",
|
||||||
"h12": "12-hour (AM/PM)",
|
"h12": "12-hour (AM/PM)",
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
MessageSquare,
|
MessageSquare,
|
||||||
BellRing,
|
BellRing,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
|
X,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import * as LucideIcons from "lucide-react";
|
import * as LucideIcons from "lucide-react";
|
||||||
import type { LucideIcon } from "lucide-react";
|
import type { LucideIcon } from "lucide-react";
|
||||||
@@ -139,12 +140,16 @@ function SortableClockTile({
|
|||||||
hour12,
|
hour12,
|
||||||
size,
|
size,
|
||||||
onToggleSize,
|
onToggleSize,
|
||||||
|
onHide,
|
||||||
|
hideLabel,
|
||||||
}: {
|
}: {
|
||||||
time: Date;
|
time: Date;
|
||||||
lang: string;
|
lang: string;
|
||||||
hour12: boolean | null | undefined;
|
hour12: boolean | null | undefined;
|
||||||
size: HomeClockSize;
|
size: HomeClockSize;
|
||||||
onToggleSize: () => void;
|
onToggleSize: () => void;
|
||||||
|
onHide: () => void;
|
||||||
|
hideLabel: string;
|
||||||
}) {
|
}) {
|
||||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
||||||
id: CLOCK_TILE_ID,
|
id: CLOCK_TILE_ID,
|
||||||
@@ -212,7 +217,7 @@ function SortableClockTile({
|
|||||||
onPointerCancel={onPointerUp}
|
onPointerCancel={onPointerUp}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`icon-tile flex items-center justify-center bg-white/85 dark:bg-white/10 backdrop-blur-md text-foreground group-hover:scale-105 group-active:scale-95 ${
|
className={`relative icon-tile flex items-center justify-center bg-white/85 dark:bg-white/10 backdrop-blur-md text-foreground group-hover:scale-105 group-active:scale-95 ${
|
||||||
isLarge ? "w-[168px] h-[168px]" : "w-[78px] h-[78px]"
|
isLarge ? "w-[168px] h-[168px]" : "w-[78px] h-[78px]"
|
||||||
}`}
|
}`}
|
||||||
aria-label="Clock"
|
aria-label="Clock"
|
||||||
@@ -224,6 +229,24 @@ function SortableClockTile({
|
|||||||
size={px - (isLarge ? 16 : 10)}
|
size={px - (isLarge ? 16 : 10)}
|
||||||
showLabels={false}
|
showLabels={false}
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={hideLabel}
|
||||||
|
title={hideLabel}
|
||||||
|
onPointerDown={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
clearTimer();
|
||||||
|
}}
|
||||||
|
onPointerUp={(e) => e.stopPropagation()}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
clearTimer();
|
||||||
|
onHide();
|
||||||
|
}}
|
||||||
|
className="absolute top-1 end-1 opacity-70 hover:opacity-100 focus:opacity-100 transition-opacity bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full w-5 h-5 flex items-center justify-center shadow-sm"
|
||||||
|
>
|
||||||
|
<X size={12} />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-[11px] text-foreground/85 font-medium text-center leading-tight max-w-[78px] truncate">
|
<span className="text-[11px] text-foreground/85 font-medium text-center leading-tight max-w-[78px] truncate">
|
||||||
{formatTime(time, lang, {
|
{formatTime(time, lang, {
|
||||||
@@ -292,7 +315,7 @@ export default function HomePage() {
|
|||||||
useSensor(TouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),
|
useSensor(TouchSensor, { activationConstraint: { delay: 250, tolerance: 5 } }),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [homeClockVisible] = useHomeClockVisibility();
|
const [homeClockVisible, setHomeClockVisible] = useHomeClockVisibility();
|
||||||
const [clockSize, setClockSize] = useHomeClockSize(user?.id);
|
const [clockSize, setClockSize] = useHomeClockSize(user?.id);
|
||||||
const [clockPos, setClockPos] = useHomeClockPosition(user?.id);
|
const [clockPos, setClockPos] = useHomeClockPosition(user?.id);
|
||||||
const toggleClockSize = () => setClockSize(clockSize === "large" ? "compact" : "large");
|
const toggleClockSize = () => setClockSize(clockSize === "large" ? "compact" : "large");
|
||||||
@@ -532,6 +555,8 @@ export default function HomePage() {
|
|||||||
hour12={user?.clockHour12 ?? null}
|
hour12={user?.clockHour12 ?? null}
|
||||||
size={clockSize}
|
size={clockSize}
|
||||||
onToggleSize={toggleClockSize}
|
onToggleSize={toggleClockSize}
|
||||||
|
onHide={() => setHomeClockVisible(false)}
|
||||||
|
hideLabel={t("home.clockStyle.hideWidget")}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user