Files
Rivertalk/river_connect/assets/js/components/SolidApp.jsx
T

77 lines
4.0 KiB
React
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { createSignal } from "solid-js";
import { Popover } from "@kobalte/core";
export function SolidApp(props) {
// Local state for optimistic updates or other UI-only logic
const [isUpdating, setIsUpdating] = createSignal(false);
const increment = () => {
setIsUpdating(true);
props.push("increment", {});
};
const decrement = () => {
setIsUpdating(true);
props.push("decrement", {});
};
return (
<div class="p-6 border-2 border-blue-500 rounded-2xl bg-white shadow-xl max-w-sm mx-auto">
<h2 class="text-2xl font-black text-blue-700 mb-6 tracking-tight">Solid + Kobalte</h2>
<div class="flex items-center justify-between mb-8 p-4 bg-slate-50 rounded-xl border border-slate-100">
<div class="flex flex-col">
<span class="text-xs font-bold text-slate-400 uppercase tracking-widest">Current Count</span>
<span class="text-5xl font-black text-slate-900">{props.state.count}</span>
</div>
<div class="flex flex-col space-y-2">
<button
onClick={increment}
class="w-12 h-12 bg-indigo-600 text-white rounded-full flex items-center justify-center hover:bg-indigo-700 transition-all active:scale-90 shadow-lg shadow-indigo-200"
>
<span class="text-2xl">+</span>
</button>
<button
onClick={decrement}
class="w-12 h-12 bg-slate-200 text-slate-600 rounded-full flex items-center justify-center hover:bg-slate-300 transition-all active:scale-90"
>
<span class="text-2xl"></span>
</button>
</div>
</div>
<div class="flex justify-center">
<Popover.Root>
<Popover.Trigger class="px-6 py-2.5 bg-slate-900 text-white text-sm font-bold rounded-full hover:bg-slate-800 transition-colors flex items-center space-x-2">
<span>Kobalte Info</span>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</Popover.Trigger>
<Popover.Portal>
<Popover.Content class="z-50 w-64 p-4 bg-white rounded-xl shadow-2xl border border-slate-100 animate-in fade-in zoom-in-95 duration-200 origin-top">
<Popover.Arrow class="text-white fill-current" />
<div class="flex flex-col">
<Popover.Title class="text-sm font-bold text-slate-900 mb-1">Kobalte Logic</Popover.Title>
<Popover.Description class="text-xs text-slate-500 leading-relaxed">
Kobalte is a headless UI toolkit for Solid.js. It provides the logic while you provide the styles!
</Popover.Description>
<Popover.CloseButton class="absolute top-2 right-2 text-slate-400 hover:text-slate-600">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</Popover.CloseButton>
</div>
</Popover.Content>
</Popover.Portal>
</Popover.Root>
</div>
<p class="mt-8 text-[10px] text-slate-400 font-bold uppercase tracking-tighter text-center">
Bridge: Phoenix LiveView &harr; Solid.js
</p>
</div>
);
}