UNPKG

@stephane1920/ts-datepicker-react

Version:

Installation: Run the following command: `npm install @stephane1920/ts-dropdown-react`

390 lines (389 loc) 8.34 kB
.date-picker { box-sizing: border-box; position: relative; display: flex; flex-direction: row; align-items: center; width: 100%; font-size: 1rem; max-width: 250px; min-height: 30px; color: var(--text-color); } .date-picker .input-date { position: relative; width: 100%; max-width: 250px; margin-top: 15px; margin-bottom: 10px; flex: 1 1 auto; cursor: pointer; } .date-picker .input-date label, .date-picker .input-date input { padding: 5px 10px; pointer-events: none; color: var(--text-color); } .date-picker .input-date__content { position: relative; display: flex; flex-direction: row; align-items: center; border: none; border: 1px solid var(--border-color); color: var(--text-color); border-radius: 5px; background-color: white; width: 100%; z-index: -1; } .date-picker .input-date__content i { width: 30px; display: block; padding: 5px 10px; line-height: 18px; color: var(--text-color); } .date-picker .input-date__content input { flex: 1 1 auto; width: 100%; outline: none; border: none; font-size: 1rem; line-height: 1rem; transition: border 0.3s ease-in-out; z-index: 2; border-radius: 5px; background: transparent; color: var(--text-color); } .date-picker .input-date label { position: absolute; top: 0; left: 0; opacity: 0.5; font-size: 1rem; line-height: 1.2rem; transform-origin: center left; transition: transform 0.15s ease-in-out; } .date-picker .input-date label.indent { left: 25px; } .date-picker .input-date__error-message { box-sizing: border-box; position: absolute; margin: 0; padding: 0; right: 0; bottom: -12px; font-size: 0.6rem; color: var(--error-color) !important; animation: error 0.25s ease-in both; } .date-picker .input-date--active label { font-size: 0.95rem !important; opacity: 1; transform: translate(-5px, -85%) scale(0.85); } .date-picker .input-date--focus label, .date-picker .input-date--focus i { color: var(--focus-color) !important; } .date-picker .input-date--focus .input__content { border-color: var(--focus-color); } .date-picker .input-date--error label, .date-picker .input-date--error input, .date-picker .input-date--error i { color: var(--error-color) !important; } .date-picker .input-date--error .input-date__content { border: 1px solid var(--error-color); } .date-picker .picker { box-sizing: border-box; position: absolute !important; top: 50px; left: 0; width: 100%; z-index: 10; transform-origin: top; display: none; opacity: 0; transform: scale(0.6); } .date-picker .picker.hide { display: block; pointer-events: none; animation: hide-picker 0.15s ease-in both; } .date-picker .picker.show { display: block; animation: show-picker 0.15s ease-out both; } @keyframes error { 0% { opacity: 0; transform: translateX(3px); } 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-3px); } 100% { opacity: 1; transform: translateX(0px); } } @keyframes show-picker { 0% { opacity: 0; transform: scale(0.6); } 100% { opacity: 1; transform: scale(1); } } @keyframes hide-picker { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.6); } } .date-picker-calendar { position: relative; font-family: Arial, Helvetica, sans-serif; left: 50%; display: flex; flex-direction: column; border-radius: 10px; background-color: #f5f4f6; min-width: 240px; max-width: 300px; width: 100%; height: 260px; font-size: 12px; overflow: hidden; transform: translateX(-50%); color: var(--text-color); } .date-picker-calendar__shadow { box-shadow: rgba(0, 0, 0, 0.1) 0px 20px 25px -5px, rgba(0, 0, 0, 0.04) 0px 10px 10px -5px; } .date-picker-calendar .controls { display: flex; flex: 1 0 auto; justify-content: space-between; max-width: 300px; gap: 10px; } .date-picker-calendar__header { box-sizing: border-box; position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 10px 5px; background-color: gray; height: 40px; color: white; } .date-picker-calendar__header p { margin: 0; padding: 0; } .date-picker-calendar__header button { appearance: none; outline: none; background-color: transparent; border: none; height: 100%; color: white; cursor: pointer; opacity: 1; transition: opacity 0.15s ease-in-out; } .date-picker-calendar__header button:hover { opacity: 0.6; } .date-picker-calendar__header p { font-size: 14px !important; display: flex; justify-content: center; gap: 10px; } .date-picker-calendar__header__month, .date-picker-calendar__header__year { cursor: pointer; opacity: 1; transition: opacity 0.15s ease-in-out; } .date-picker-calendar__header__month:hover, .date-picker-calendar__header__year:hover { opacity: 0.6; } .date-picker-calendar__header__year { font-weight: bold; } .date-picker-calendar__table { text-align: center; top: 50px; left: 0; height: 200px; width: 96%; position: absolute; padding: 2%; cursor: pointer; } .date-picker-calendar__table__days { height: 100%; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, 1fr); grid-column-gap: 0px; grid-row-gap: 0px; align-items: center; justify-items: center; transform: scale(1); opacity: 1; } .date-picker-calendar__table__days div { height: 27px; width: 27px; line-height: 27px; text-align: center; } .date-picker-calendar__table__days div:hover { opacity: 0.5; } .date-picker-calendar__table__days .day { position: relative; border-radius: 50%; } .date-picker-calendar__table__days .day span { position: absolute; height: 27px; width: 27px; top: 50%; left: 50%; transform: translate(-50%, -50%); } .date-picker-calendar__table__days .day::before { content: ""; position: absolute; top: 50%; left: 50%; height: 22px; width: 22px; background-color: var(--primary-color) !important; border-radius: 50%; opacity: 0; transform: translate(-50%, -50%); transition: opacity 0.2s ease-in-out; } .date-picker-calendar__table__days .day--grey { opacity: 0.3; } .date-picker-calendar__table__days .day-selected { color: white; font-weight: bold; } .date-picker-calendar__table__days .day-selected::before { background-color: var(--primary-color) !important; opacity: 0.8 !important; } .date-picker-calendar__table__days .day-label { font-weight: bold; pointer-events: none; } .date-picker-calendar__table__days .day-current { font-weight: bold; } .date-picker-calendar__table__days .day-current::before { background-color: inherit !important; border: 1px solid; opacity: 0.3; } .date-picker-calendar__table__months { position: absolute; top: 0; left: 0; height: 100%; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); grid-column-gap: 0px; grid-row-gap: 0px; align-items: center; justify-items: center; transition: all 0.15s ease-in-out; transform: scale(0.8); opacity: 0; } .date-picker-calendar__table__months .month { opacity: 1; transition: 0.1s ease-in-out; } .date-picker-calendar__table__months .month:hover { opacity: 0.5; } .date-picker-calendar__table__years { position: absolute; top: 0; right: 0; height: 100%; width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); grid-column-gap: 0px; grid-row-gap: 0px; align-items: center; justify-items: center; overflow: auto; z-index: 1; transition: all 0.15s ease-in-out; transform: scale(0.8); opacity: 0; } .date-picker-calendar__table__years .year { height: 30px; opacity: 1; transition: 0.1s ease-in-out; } .date-picker-calendar__table__years .year:hover { opacity: 0.5; } .date-picker-calendar .show-table { animation: show-table 0.3s ease-in 0.1s both; } .date-picker-calendar .hide-table { pointer-events: none; animation: hide-table 0.1s ease-in both; } @keyframes show-table { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } } @keyframes hide-table { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.8); opacity: 0; } }