@adhikarisaroj795/nepali-calendar-react
Version:
A comprehensive Nepali calendar component for React applications
324 lines (282 loc) • 6.51 kB
CSS
*,
*::before,
*::after {
box-sizing: border-box;
}
.nepali-calendar-container {
position: relative;
font-family: "Mukta", "Noto Sans Devanagari", sans-serif;
width: 100%;
/* max-width: 320px; */
color: #333;
}
.nepali-calendar-input-wrapper {
position: relative;
margin-bottom: 5px;
}
.nepali-calendar-input {
width: 100%;
padding: 10px 15px;
padding-right: 35px;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 16px;
background-color: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
transition: all 0.2s ease;
font-family: inherit;
}
.nepali-calendar-input:focus {
outline: none;
border-color: var(--calendar-color, #4f46e5);
box-shadow: 0 0 0 3px var(--calendar-color-light, rgba(79, 70, 229, 0.2));
}
.nepali-calendar-input.disabled {
background-color: #f9fafb;
color: #6b7280;
cursor: not-allowed;
}
.nepali-calendar-icon {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
color: #6b7280;
pointer-events: none;
}
.nepali-calendar-icon > svg {
width: 30px;
height: 30px;
}
.nepali-calendar-popup {
position: absolute;
top: calc(100% + 5px);
left: 0;
z-index: 50;
width: 100%;
background-color: #fff;
border: 1px solid #e5e7eb;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
overflow: hidden;
animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-5px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Calendar Header */
.nepali-calendar-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 10px;
background-color: var(--calendar-color, #4f46e5);
color: white;
}
.nepali-calendar-nav-button {
background: none;
border: none;
color: white;
font-size: 18px;
width: 32px;
height: 32px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.2s;
}
.nepali-calendar-nav-button:hover {
background-color: rgba(255, 255, 255, 0.2);
}
.nepali-calendar-month-selector {
display: flex;
align-items: center;
gap: 8px;
}
.nepali-calendar-year-select {
padding: 5px 8px;
border: none;
border-radius: 6px;
background-color: rgba(255, 255, 255, 0.2) ;
color: white;
font-family: inherit;
font-size: 14px;
cursor: pointer;
}
.nepali-calendar-year-select option {
color: #111;
}
.nepali-calendar-year-select:focus {
outline: none;
background-color: rgba(255, 255, 255, 0.3);
}
.nepali-calendar-month-name {
font-weight: 600;
font-size: 15px;
min-width: 70px;
text-align: center;
}
/* Calendar Grid */
.nepali-calendar-grid {
padding: 10px;
}
.nepali-calendar-weekdays {
display: grid;
grid-template-columns: repeat(7, 1fr);
margin-bottom: 8px;
text-align: center;
}
.nepali-calendar-weekday {
font-size: 13px;
font-weight: 600;
color: var(--calendar-color, #4f46e5);
padding: 5px 0;
}
.nepali-calendar-days {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 4px;
}
.nepali-calendar-day {
aspect-ratio: 1;
display: flex;
align-items: center;
justify-content: center;
border: none;
background: none;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
font-family: inherit;
}
.nepali-calendar-day:hover {
background-color: #f3f4f6;
}
.nepali-calendar-day.selected {
background-color: var(--calendar-color, #4f46e5);
color: white;
font-weight: 600;
}
.nepali-calendar-day.today {
background-color: var(--calendar-color-light, #e0e7ff);
color: var(--calendar-color, #4f46e5);
font-weight: 600;
}
.nepali-calendar-day.disabled {
color: #d1d5db;
cursor: not-allowed;
background: none;
}
.nepali-calendar-day.disabled:hover {
background: none;
}
/* Calendar Footer */
.nepali-calendar-footer {
display: flex;
justify-content: space-between;
padding: 10px 15px;
border-top: 1px solid #e5e7eb;
background-color: #f9fafb;
}
.nepali-calendar-today-button,
.nepali-calendar-close-button {
padding: 6px 12px;
border: none;
border-radius: 6px;
background: none;
font-family: inherit;
font-size: 14px;
cursor: pointer;
transition: background-color 0.2s;
}
.nepali-calendar-today-button {
color: var(--calendar-color, #4f46e5);
font-weight: 500;
}
.nepali-calendar-today-button:hover {
background-color: var(--calendar-color-light, #e0e7ff);
}
.nepali-calendar-today-button:disabled {
color: #9ca3af;
cursor: not-allowed;
background: none;
}
.nepali-calendar-close-button {
color: #6b7280;
}
.nepali-calendar-close-button:hover {
background-color: #e5e7eb;
}
/* Responsive Adjustments */
@media (max-width: 400px) {
.nepali-calendar-popup {
width: 100%;
min-width: 280px;
}
}
.nepali-calendar-container {
position: relative;
display: inline-block;
}
.nepali-calendar-popup {
width: 300px; /* Adjust as needed */
background: white;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
border-radius: 4px;
margin-top: 5px;
}
/* For positioning above */
.nepali-calendar-popup.above {
bottom: 100%;
top: auto;
margin-bottom: 5px;
margin-top: 0;
}
.nepali-calendar-input::placeholder {
color: var(--placeholder-color);
opacity: 1; /* Fix for Firefox */
transition: color 0.2s ease;
}
/* For disabled state */
.nepali-calendar-input.disabled::placeholder {
opacity: 0.5;
}
/* Placeholder styling */
.nepali-calendar-input::placeholder {
color: var(--placeholder-color) ;
opacity: 1 ; /* Required for Firefox */
}
/* Fallback for older browsers */
.nepali-calendar-input::-webkit-input-placeholder {
/* Chrome/Opera/Safari */
color: var(--placeholder-color);
}
.nepali-calendar-input::-moz-placeholder {
/* Firefox 19+ */
color: var(--placeholder-color);
opacity: 1;
}
.nepali-calendar-input:-ms-input-placeholder {
/* IE 10+ */
color: var(--placeholder-color);
}
.nepali-calendar-input:-moz-placeholder {
/* Firefox 18- */
color: var(--placeholder-color);
opacity: 1;
}
.nepali-calendar-input ::placeholder {
font-weight: bold;
opacity: 0.5;
color: red;
}