UNPKG

temporal-react-hook

Version:

A React library that provides hooks for handling date and time operations using the Temporal API

804 lines (699 loc) 14.7 kB
/* Card container for demo components */ .demo-card { background: #ffffff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); margin-bottom: 2rem; width: 100%; height: 100%; max-width: none; margin-left: 0; margin-right: 0; transition: box-shadow 0.2s; padding: 0 1.5rem; overflow-y: auto; } .demo-card:hover { box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08); } .demo-card h3 { font-size: 1.3rem; color: #1a202c; margin-bottom: 1.25rem; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-weight: 600; padding-bottom: 0.5rem; border-bottom: 1px solid #edf2f7; } .demo-card label, .demo-card b { color: #4a5568; font-weight: 600; font-size: 0.95rem; letter-spacing: 0.01em; } .demo-card label { display: flex; align-items: center; flex-wrap: wrap; } .demo-card b { min-width: 120px; } .demo-card input[type="text"], .demo-card input[type="number"], .demo-card input[type="datetime-local"], .demo-input, .demo-card select { border: 1px solid #e2e8f0; border-radius: 4px; padding: 0.5rem 0.75rem; margin-left: 0.5rem; font-size: 0.95rem; outline: none; transition: border 0.2s; flex: 1; min-width: 200px; max-width: 100%; } .demo-card input:focus { border-color: #4299e1; box-shadow: 0 0 0 1px rgba(66, 153, 225, 0.5); } .demo-card button { background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 4px; color: #2d3748; padding: 0.5rem 1rem; margin-left: 0.5rem; font-size: 0.95rem; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-weight: 500; cursor: pointer; transition: all 0.2s; } .demo-card button:hover, .demo-card button:focus { background: #4299e1; color: #fff; border-color: #4299e1; } .demo-card button.active { background: #4299e1 !important; color: #fff !important; border-color: #4299e1 !important; } .demo-card .demo-row { margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: flex-start; text-align: left; width: 100%; flex-wrap: wrap; } .demo-card .demo-row:last-child { margin-bottom: 0; } .demo-card .demo-value { margin-left: 0.75rem; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; color: #3182ce; font-size: 0.95rem; word-break: break-word; max-width: 100%; } .demo-desc { margin-bottom: 1.2rem; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.95rem; color: #4a5568; line-height: 1.5; } .demo-usage { margin-top: 0.75rem; font-size: 0.95rem; } .demo-usage code { display: block; background: #f8fafc; padding: 10px 12px; border-radius: 4px; margin-top: 4px; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; color: #2c5282; font-size: 0.92rem; border: 1px solid #e2e8f0; overflow-x: auto; } .demo-info-card { margin-top: 1.5rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px; padding: 1.25rem; font-size: 0.95rem; color: #4a5568; line-height: 1.5; text-align: left; } .demo-info-card div { width: 100%; text-align: left; } .demo-info-card div strong { color: #2b6cb0; display: inline; } .demo-info-card .demo-description, .demo-info-card .demo-usage { margin-top: 0.75rem; display: flex; flex-direction: column; } .demo-info-card .demo-description strong, .demo-info-card .demo-usage strong { font-weight: 600; color: #2b6cb0; margin-bottom: 0.35rem; } .demo-info-card div code { display: inline; background: #edf2f7; color: #2c5282; padding: 2px 5px; border-radius: 3px; font-size: 0.9rem; border: none; margin: 0; } .demo-info-card .demo-usage code { display: block; background: #edf2f7; color: #2c5282; padding: 10px 12px; border-radius: 4px; margin-top: 6px; font-size: 0.92rem; border: 1px solid #e2e8f0; overflow-x: auto; line-height: 1.4; width: 100%; box-sizing: border-box; text-align: left; } .demo-controls { margin-bottom: 20px; padding: 10px; background-color: #f5f5f5; border-radius: 4px; display: flex; flex-direction: column; gap: 1rem; } .format-selector { display: flex; align-items: center; gap: 10px; } .format-select { padding: 5px; border-radius: 4px; border: 1px solid #ccc; font-size: 0.95rem; outline: none; } .demo-times-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; } @media (max-width: 768px) { .demo-times-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; } } @media (max-width: 480px) { .demo-times-grid { grid-template-columns: 1fr; gap: 8px; } .demo-time-item { padding: 8px; } .time-value { font-size: 1.1em; word-break: break-word; } .time-actual { font-size: 0.75em; } } .demo-time-item { background-color: #f9f9f9; border: 1px solid #eee; border-radius: 4px; padding: 10px; } .time-label { font-weight: bold; margin-bottom: 5px; color: #2b6cb0; } .time-value { color: #0066cc; font-size: 1.2em; margin-bottom: 5px; } .time-actual { font-size: 0.8em; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } pre { background: #f4f4f4; border: 1px solid #ddd; border-left: 3px solid #2b6cb0; color: #666; page-break-inside: avoid; font-family: monospace; font-size: 15px; line-height: 1.6; margin-bottom: 1.6em; max-width: 100%; overflow: auto; padding: 1em 1.5em; display: block; word-wrap: break-word; } .demo-select-btn { background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 4px; color: #2d3748; padding: 0.5rem 1rem; margin-left: 0.5rem; font-size: 0.95rem; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-weight: 500; cursor: pointer; transition: all 0.2s; outline: none; box-shadow: none; } .demo-select-btn:hover, .demo-select-btn:focus { background: #4299e1; color: #fff; border-color: #4299e1; } .demo-select-btn.active { background: #4299e1 !important; color: #fff !important; border-color: #4299e1 !important; } /* Configuration panel styles */ .demo-config-panel { background: #f8fafc; border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem; border: 1px solid #e2e8f0; } .demo-config-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; } .demo-config-row:last-child { margin-bottom: 0; } .demo-config-row span { font-size: 0.95rem; font-weight: 500; color: #4a5568; } .demo-btn-group { display: flex; gap: 0.5rem; } /* Responsive styles for config panel */ @media (max-width: 768px) { .demo-config-panel { padding: 0.75rem; } .demo-config-row { flex-direction: column; align-items: flex-start; margin-bottom: 1rem; } .demo-config-row span { margin-bottom: 0.5rem; } .demo-btn-group { width: 100%; flex-direction: column; gap: 0.5rem; } .demo-select-btn { width: 100%; min-width: 0; padding: 0.5rem; font-size: 0.9rem; white-space: normal; height: auto; line-height: 1.2; margin-left: 0; } } @media (max-width: 480px) { .demo-config-panel { padding: 0.5rem; margin-bottom: 1rem; } .demo-btn-group { gap: 0.25rem; } .demo-select-btn { width: 100%; min-width: 0; padding: 0.4rem; font-size: 0.85rem; white-space: normal; height: auto; line-height: 1.2; min-height: 36px; display: flex; align-items: center; justify-content: center; text-align: center; margin-left: 0; } .demo-value { word-break: break-word; } } /* Options table styles */ .demo-options-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.95rem; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); } .demo-options-table th, .demo-options-table td { padding: 0.75rem 1rem; text-align: left; border: 1px solid #e2e8f0; } .demo-options-table th { background-color: #f1f5f9; font-weight: 600; color: #334155; } .demo-options-table tr:nth-child(even) { background-color: #f8fafc; } .demo-options-table code { background-color: #edf2f7; padding: 0.2rem 0.4rem; border-radius: 4px; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 0.9em; color: #3182ce; } .demo-options { margin-top: 1.5rem; margin-bottom: 1.5rem; } .demo-options strong { display: block; margin-bottom: 0.75rem; font-size: 1.05rem; color: #2d3748; } /* Make table responsive on mobile */ @media (max-width: 640px) { .demo-options-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; } .demo-options-table th, .demo-options-table td { padding: 0.6rem 0.8rem; font-size: 0.9rem; } } .demo-input-wide { width: 320px; padding: 0.4rem 1rem; border-radius: 0.5rem; border: 1px solid #e0e3ea; font-size: 1rem; } .demo-btn-margin { margin-left: 8px; } .demo-btn-bold { font-weight: bold; } .demo-error-border { border-color: #ff6b6b !important; } .demo-error-color { color: #ff6b6b !important; } /* === Dart Docs-Inspired Playground Sidebar === */ .playground-sidebar-search { padding: 0.75rem 1.25rem 0.5rem 1.25rem; } .playground-sidebar-search input { width: 80%; height: 25px; font-size: 16px; border-radius: 1px; border: 1px solid grey; padding-left: 5px; outline: none; transition: border-color 0.2s; } .playground-sidebar-search input:focus { border-color: #1976d2; box-shadow: 0 0 0 1px rgba(25,118,210,0.4); } .playground-sidebar { background: #fff; color: #222; border-right: 1px solid #e5e7eb; box-shadow: 2px 0 8px 0 rgba(60,72,90,0.03); min-width: 230px; max-width: 260px; display: flex; flex-direction: column; padding: 0; } .playground-sidebar-header { font-weight: 700; font-size: 1.05rem; padding: 1.2rem 1.25rem 1rem 1.25rem; letter-spacing: 0.08em; border-bottom: 1px solid #e5e7eb; text-align: left; color: #1976d2; background: #f8fafc; text-transform: uppercase; display: flex; align-items: center; justify-content: flex-start; } .playground-sidebar-icon { margin-right: 0.6rem; font-size: 1.25rem; } .playground-sidebar-nav { flex: 1; overflow-y: auto; position: relative; display: flex; flex-direction: column; background: #fff; } .playground-nav-items { padding: 0.5rem 0.25rem 1rem 0.25rem; } .playground-nav-item { padding: 0.55rem 1.15rem; margin: 0.15rem 0.5rem; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 1rem; color: #23272f; background: none; border: none; transition: background 0.15s, color 0.15s; display: block; outline: none; position: relative; } .playground-nav-item.selected, .playground-nav-item:hover, .playground-nav-item.hovered { background: #e3f0fc; color: #1976d2; } .playground-nav-item.selected { font-weight: 700; box-shadow: 0 2px 8px 0 rgba(25,118,210,0.05); } .playground-nav-arrow { position: sticky; z-index: 2; text-align: center; pointer-events: none; font-size: 1.1rem; color: #bdbdbd; height: 2rem; display: flex; align-items: center; justify-content: center; background: #fff; } .playground-sidebar-footer { padding: 0.85rem 1.25rem; font-size: 0.85rem; color: #757575; border-top: 1px solid #e5e7eb; background: #f8fafc; text-align: left; } .playground-root { display: flex; width: 100vw; height: 100vh; font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: #f8fafc; } .playground-main { width: 100%; min-height: 100vh; display: flex; flex-direction: column; } .playground-main-content { flex: 1; display: flex; width: 100%; height: 100%; align-items: flex-start; justify-content: flex-start; padding: 2.5rem 2.5rem 2.5rem 0.5rem; box-sizing: border-box; } /* Hamburger menu button */ .playground-menu-toggle { display: none; position: absolute; top: 25px; left: 20px; z-index: 1000; background: #ffffff; color: #1976d2; border: 1px solid #e5e7eb; border-radius: 6px; transition: left 0.3s ease; width: 34px; height: 34px; padding: 5px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); transition: all 0.2s ease; outline: none; } .playground-menu-toggle:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); border-color: #d0d5dd; } .playground-menu-toggle:focus { outline: none; border-color: #e5e7eb; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); } .playground-menu-toggle:focus-visible { outline: none; } /* Hamburger icon */ .hamburger-icon { display: block; position: relative; width: 22px; height: 2px; background: #1976d2; margin: 10px auto; transition: background-color 0.2s; } .hamburger-icon:before, .hamburger-icon:after { content: ''; position: absolute; width: 22px; height: 2px; background: #1976d2; left: 0; transition: transform 0.2s; } .hamburger-icon:before { top: -7px; } .hamburger-icon:after { bottom: -7px; } /* Animate hamburger icon when menu is open */ .playground-root .playground-menu-toggle .hamburger-icon { transition: background-color 0.2s ease; } .playground-root.menu-open .playground-menu-toggle .hamburger-icon { background: transparent; } .playground-root.menu-open .playground-menu-toggle .hamburger-icon:before { transform: rotate(45deg) translate(4px, 4px); transition: transform 0.2s ease; } .playground-root.menu-open .playground-menu-toggle .hamburger-icon:after { transform: rotate(-45deg) translate(4px, -4px); transition: transform 0.2s ease; } /* Menu open state - change button position */ .playground-root.menu-open .playground-menu-toggle { left: 8px; } /* Responsive styles for tablets and mobile */ @media (max-width: 768px) { .playground-menu-toggle { display: block; } .playground-sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 999; transition: left 0.3s ease; box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1); } .playground-sidebar.menu-open { left: 0; } .playground-main { width: 100%; margin-left: 0; } .playground-main-content { padding: 2.5rem 1.5rem; margin-top: 40px; } } /* Custom formatter styles */ .demo-format-help { margin-top: 0.5rem; width: 100%; color: #718096; font-size: 0.85rem; } .demo-input { width: 100%; padding: 0.5rem; font-family: monospace; }