@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
52 lines • 3.77 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
import { TimeZonePicker } from '@neo4j-ndl/react';
import { useState } from 'react';
const Component = () => {
const [selectedTimeZone, setSelectedTimeZone] = useState('Europe/Stockholm');
const [referenceDate, setReferenceDate] = useState(new Date('2025-01-01'));
// Create summer and winter dates for DST demonstration
const summerDate = new Date('2024-07-15T12:00:00'); // July (DST in effect)
const winterDate = new Date('2024-01-15T12:00:00'); // January (Standard time)
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '2rem' }, children: [_jsxs("div", { children: [_jsx("h3", { style: { marginBottom: '1rem' }, children: "DST-Aware Timezone Picker Demo" }), _jsx("p", { style: { color: '#666', marginBottom: '1rem' }, children: "The timezone offsets change based on the reference date to account for Daylight Saving Time." })] }), _jsxs("div", { style: { display: 'flex', gap: '1rem', marginBottom: '1rem' }, children: [_jsx("button", { type: "button", onClick: () => setReferenceDate(summerDate), style: {
backgroundColor: referenceDate === summerDate ? '#0066cc' : 'white',
border: '1px solid #ccc',
borderRadius: '4px',
color: referenceDate === summerDate ? 'white' : 'black',
cursor: 'pointer',
padding: '0.5rem 1rem',
}, children: "Summer Date (July 15, 2024)" }), _jsx("button", { type: "button", onClick: () => setReferenceDate(winterDate), style: {
backgroundColor: referenceDate === winterDate ? '#0066cc' : 'white',
border: '1px solid #ccc',
borderRadius: '4px',
color: referenceDate === winterDate ? 'white' : 'black',
cursor: 'pointer',
padding: '0.5rem 1rem',
}, children: "Winter Date (January 15, 2024)" })] }), _jsx(TimeZonePicker, { label: "Select Timezone", value: selectedTimeZone, onChange: setSelectedTimeZone, referenceDate: referenceDate, htmlAttributes: { id: 'time-zone-input' } }), _jsxs("div", { style: {
backgroundColor: '#f5f5f5',
borderRadius: '4px',
padding: '1rem',
}, children: [_jsxs("p", { children: [_jsx("strong", { children: "Selected Timezone:" }), " ", selectedTimeZone] }), _jsxs("p", { children: [_jsx("strong", { children: "Reference Date:" }), " ", referenceDate.toLocaleDateString()] }), _jsxs("p", { children: [_jsx("strong", { children: "Example:" }), " New York shows GMT-4 in summer (EDT) and GMT-5 in winter (EST)"] })] })] }));
};
export default Component;
//# sourceMappingURL=timezone-picker-dst-aware.story.js.map