UNPKG

hamro-nepali-patro

Version:

A modern React component library for Nepali (Bikram Sambat, BS) and Gregorian (AD) calendar date picking, conversion, and utilities. Includes a customizable datepicker, BS/AD conversion, and Nepali date functions.

530 lines (471 loc) 10.3 kB
:root { --cl-primary: #3851a3; --cl-primary2: rgba(56, 81, 163, 0.2); --cl-danger: #f15c61; --cl-success: #3fbeb2; --cl-secondary: #878f9d; --font-xs: 0.64rem; --font-sm: 0.8rem; --font-md: 1rem; --font-lg: 1.25rem; --font-xl: 1.563rem; --font-xxl: 2rem; --font-r: 0.875rem; --gray90: #1d2530; --gray80: #343c46; --gray60: #636972; --gray50: #91979f; --gray20: #afb5bb; --gray10: #cbd0d6; --gray5: #eef2f7; --debit: #143e9f; --link: #143e9f; --credit: #fc814a; --white: #fff; --danger: #ff6b6b; } .font-sm { font-size: var(--font-sm); } .font-md { font-size: var(--font-md); } .gray-60 { color: var(--gray60); } .gray-20 { color: var(--gray20); } .flex { display: flex; } .input-wrapper { position: relative; display: flex; align-items: center; width: 100%; min-width: 0; padding: 0; background-color: transparent; border:none; border-radius: 6px; box-shadow: 0 1px 4px rgba(56, 81, 163, 0.07); transition: border 0.2s, box-shadow 0.2s; } /* .input-wrapper:focus-within { border-color: var(--cl-primary); box-shadow: 0 2px 8px rgba(56, 81, 163, 0.15); } */ .rl-nepali-datepicker-input { width: 100%; padding: 10px 36px 10px 1.8rem; border: 1px solid #d7d6d6; outline: none; font-size: 1rem; background: transparent; border-radius: 6px; color: var(--gray90); } .rl-nepali-datepicker-input::placeholder { color: var(--datepicker-placeholder-color, #aaa); } .icon-left { position: absolute; left: .2rem; display: flex; align-items: center; height: 100%; z-index: 2; } .icon-right { position: absolute; right: 2.5rem; display: flex; align-items: center; height: 100%; z-index: 2; } .icon-right .cross-icon { opacity: 1; cursor: pointer; transition: background 0.2s; background: var(--cl-secondary); color: #fff; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; font-size: 14px; } .cross-icon:hover { background: var(--cl-danger); cursor: pointer; } .rl-nepali-datepicker-icon { width: 20px; height: 20px; filter: invert(59%) sepia(19%) saturate(232%) hue-rotate(179deg) brightness(93%) contrast(86%); cursor: pointer; transition: filter 0.2s; } /* .rl-nepali-datepicker-icon:hover { filter: invert(34%) sepia(99%) saturate(749%) hue-rotate(340deg) brightness(99%) contrast(101%); } */ @media (max-width: 600px) { .input-wrapper { font-size: 0.95rem; } .rl-nepali-datepicker-input { padding: 8px 32px 8px 32px; font-size: 0.95rem; } .icon-left, .icon-right { left: 6px; right: 6px; } } .rl-nepali-calendar__month-select { color: white; outline: none; background-color: var(--cl-primary); border: none; border-radius: 4px; padding: 4px 8px; font-size: 14px; font-weight: 600; width: 100%; cursor: pointer; } /* Style the dropdown arrow */ .rl-nepali-calendar__month-select::-ms-expand { display: none; } .rl-nepali-calendar__month-select { -webkit-appearance: none; -moz-appearance: none; appearance: none; background-position: right 8px center; background-size: 12px; padding-right: 10px; overflow-y: hidden; } /* Control select dropdown height */ .rl-nepali-calendar__month-select option { padding: 4px 8px; background-color: white; color: black; } .rl-nepali-datepicker-wrapper { position: relative; /* width: fit-content; */ } .rl-nepali-datepicker-wrapper ul { list-style-type: none; } .rl-nepali-date-panel-wrapper { display: flex; flex-direction: row; flex-wrap: nowrap; } .rl-nepali-date-referenc-list { background-color: white; width: 120px; padding-top: 20px; font-weight: normal; font-size: 12.8px; line-height: 15px; /* identical to box height */ /* Theme_Blue */ color: var(--cl-primary); overflow-y: scroll; padding-left: 10px; } .reference-item { margin-bottom: 20px; cursor: pointer; } .rl-nepali-date-panel { width: 320px; z-index: 4; background-color: white; } .rl-nepali-date-body { padding: 8px 12px; } .rl-nepali-date-panel .left-actions div, .rl-nepali-date-panel .right-actions div { color: #ddd; } .rl-nepali-date-panel .left-actions div:hover, .rl-nepali-date-panel .right-actions div:hover { color: white; } .rl-nepali-date-panel .rl-nepalo-date-body { padding: 8px 12px; } /* Month header */ .month-header { background: var(--cl-primary); text-align: center; padding: 0 8px; color: white; display: flex; flex-direction: row; align-items: center; justify-content: space-between; } .month-header-content { width: 100%; display: flex; flex-direction: row; gap: 12px; align-items: center; justify-content: space-between; } .month-header .left-actions, .month-header .right-actions { display: flex; flex-direction: row; align-items: center; } .month-header .left-actions :first-child, .month-header .right-actions :first-child { margin-right: 12px; } .rl-nepali-date-content { width: 100%; } .rl-nepali-date-content thead th { font-size: 12px; } .rl-nepali-date-content th, .rl-nepali-date-content td { color: black; font-weight: 400; } .rl-picker-cell { /* padding: 2px; */ cursor: pointer; } .rl-picker-cell .rl-picker-cell-inner { position: relative; margin: auto; min-width: 18px; width: inherit; text-align: center; height: 18px; line-height: 100%; border-radius: 2px; -webkit-transition: background 0.3s, border 0.3s; transition: background 0.3s, border 0.3s; font-size: 12px; display: flex; align-items: center; justify-content: center; } .rl-picker-cell .rl-picker-cell-inner .BS { font-size: 14px; } .rl-picker-cell .rl-picker-cell-inner .AD { position: absolute; right: 2px; bottom: 0px; font-size: 7px; } .rl-picker-cell:not(.disabled).in-range { background-color: var(--cl-primary2); } .rl-picker-cell:not(.disabled):hover .rl-picker-cell-inner { background-color: var(--cl-primary2); } .rl-picker-cell:not(.disabled).active .rl-picker-cell-inner { background-color: var(--cl-primary); color: white; } .rl-picker-cell:not(.disabled).today .rl-picker-cell-inner { border-color: var(--cl-primary); border: 1px solid; } .rl-picker-cell:not(.disabled).other-month .rl-picker-cell-inner { color: rgba(0, 0, 0, 0.4); /* background-color:var(--cl-secondary) ; */ } .rl-picker-cell.disabled { color: var(--cl-secondary); cursor: not-allowed; background-color: #ddd; } /* INLINE DROPDOWN CSS START*/ .inline-dropdown { position: relative; display: inline-block; z-index: 2; padding: 0; margin: 0; outline: 0; text-align: left; } .inline-dropdown:focus { pointer-events: none; } .inline-dropdown:focus .inline-dropdown-container { opacity: 1; visibility: visible; } /* Month dropdown opens upwards */ .month-dropdown:focus .inline-dropdown-container { bottom: 100%; top: auto; margin: 0 0 3px 0; } .inline-dropdown-container { width: auto; margin: 3px 0 0 0; padding: 10px; border-radius: 3px; border-radius: 3px; pointer-events: auto; position: absolute; z-index: 5; opacity: 0; visibility: hidden; transition: visibility 1s; max-height: 200px; overflow-y: auto; background-color: white; box-shadow: 0px 4px 10px rgba(19, 31, 54, 0.25); border-radius: 4px; color: black; } .inline-dropdown-container .inline-dropdown-item { cursor: pointer; padding-left: 8px; padding-right: 8px; } .inline-dropdown-container .inline-dropdown-item:hover { background-color: var(--cl-primary2); } .inline-dropdown-container .inline-dropdown-item.selected { background-color: var(--cl-primary); color: white; } .inline-dropdown .value { color: white; cursor: pointer; padding: 4px 8px; border-radius: 4px; background-color: var(--cl-primary); display: inline-block; min-width: 60px; text-align: center; } /* INLINE DROPDOWN CSS END */ .rl-range-calendar { display: flex; flex-wrap: nowrap; width: fit-content; } .rl-nepali-rangepicker-wrapper .input-split { background-color: #fff; } .rl-nepali-rangepicker-wrapper .input-right { border-left-width: 0; } .rl-nepali-rangepicker-wrapper .input-right:hover, .rl-nepali-rangepicker-wrapper .input-right:focus { border-left-width: 1px; } .rl-daterange-toggler { display: flex; flex-wrap: nowrap; width: fit-content; /* background-color: var(--cl-success); */ } .rl-daterange-toggler .rl-daterange-toggler-content { display: flex; flex-wrap: nowrap; width: fit-content; margin-left: 8px; } .rl-daterange-toggler .rl-daterange-toggler-content .label-body { margin-left: 12px; margin-right: 12px; } .rl-daterange-toggler .rl-daterange-toggler-content .switch { width: 20px; height: 20px; border-radius: 50%; background-color: var(--cl-primary2); display: flex; justify-content: center; align-items: center; } .rl-daterange-toggler .selector-main { display: flex; } .rl-daterange-toggler .down-arrow { font-size: 110%; line-height: 0.9rem; margin-left: 8px; } .selector-content-wrapper .selector-content { display: flex; flex-direction: column; } .selector-content-wrapper { display: flex; } .cross-icon { position: absolute; z-index: 1; background: var(--cl-secondary); font-size: 10px; line-height: 100%; display: flex; justify-content: center; align-items: center; border-radius: 50%; color: white; opacity: 0; width: 10px; height: 10px; top: 50%; transform: translateY(-50%); right: 5px; padding: 0px; margin: 0px; font-size: 12px; padding: 2px; opacity: 1; } .rl-defined-range-selector { z-index: 4; background-color: white; padding: 4px 6px; font-weight: 400; width: fit-content; display: flex; } .rl-defined-range-selector .rl-defined-range-label-wrapper { display: flex; flex-direction: column; border-right: 1px solid var(--gray20); margin-right: 10px; width: 300px; } .rl-defined-range-selector .rl-defined-range-label-wrapper .rl-defined-range-label { padding: 12px; } .rl-defined-range-selector .rl-defined-range-label-wrapper .rl-defined-range-label:hover { background: var(--cl-primary2); cursor: pointer; } .rl-defined-range-label-selected { background: var(--cl-primary2) !important; }