@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
54 lines • 4.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("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/>.
*/
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
const react_1 = require("@neo4j-ndl/react");
const react_2 = require("react");
const Component = () => {
const [selectedTimeZone, setSelectedTimeZone] = (0, react_2.useState)('Europe/Stockholm');
const [referenceDate, setReferenceDate] = (0, react_2.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 ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '2rem' }, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { style: { marginBottom: '1rem' }, children: "DST-Aware Timezone Picker Demo" }), (0, jsx_runtime_1.jsx)("p", { style: { color: '#666', marginBottom: '1rem' }, children: "The timezone offsets change based on the reference date to account for Daylight Saving Time." })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '1rem', marginBottom: '1rem' }, children: [(0, jsx_runtime_1.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)" }), (0, jsx_runtime_1.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)" })] }), (0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Select Timezone", value: selectedTimeZone, onChange: setSelectedTimeZone, referenceDate: referenceDate, htmlAttributes: { id: 'time-zone-input' } }), (0, jsx_runtime_1.jsxs)("div", { style: {
backgroundColor: '#f5f5f5',
borderRadius: '4px',
padding: '1rem',
}, children: [(0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Selected Timezone:" }), " ", selectedTimeZone] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Reference Date:" }), " ", referenceDate.toLocaleDateString()] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Example:" }), " New York shows GMT-4 in summer (EDT) and GMT-5 in winter (EST)"] })] })] }));
};
exports.default = Component;
//# sourceMappingURL=timezone-picker-dst-aware.story.js.map