fix: refactor layout and styling for SingleWeekPicker component
All checks were successful
Publish to npm / publish (push) Successful in 29s
All checks were successful
Publish to npm / publish (push) Successful in 29s
This commit is contained in:
parent
ac798d2e67
commit
5c03b4ce50
|
@ -10,8 +10,9 @@ export default () => {
|
||||||
|
|
||||||
return (<div className='app'>
|
return (<div className='app'>
|
||||||
<div className="border">
|
<div className="border">
|
||||||
|
<div>
|
||||||
<SingleWeekPicker />
|
<SingleWeekPicker />
|
||||||
<SingleDatePicker />
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>)
|
</div>)
|
||||||
}
|
}
|
|
@ -121,7 +121,7 @@ const SingleDatePicker: React.FC<SingleDatePickerProps> = ({ value, onSelect, lo
|
||||||
hoverColor: hoverColor,
|
hoverColor: hoverColor,
|
||||||
borderColor: borderColor
|
borderColor: borderColor
|
||||||
})
|
})
|
||||||
} , [mainColor, accentColor, reversedColor, hoverColor, borderColor])
|
}, [mainColor, accentColor, reversedColor, hoverColor, borderColor])
|
||||||
|
|
||||||
function selectDate(date: Date) {
|
function selectDate(date: Date) {
|
||||||
setSelectedDate(date)
|
setSelectedDate(date)
|
||||||
|
@ -175,6 +175,7 @@ const SingleDatePicker: React.FC<SingleDatePickerProps> = ({ value, onSelect, lo
|
||||||
setCurrentYear(currentYear + 1)
|
setCurrentYear(currentYear + 1)
|
||||||
}} aria-label={`Go to next year, ${currentYear + 1}, you are now at year ${currentYear}`}> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path></svg></button>
|
}} aria-label={`Go to next year, ${currentYear + 1}, you are now at year ${currentYear}`}> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path></svg></button>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='body'>
|
||||||
<div className='month-selector-body'>
|
<div className='month-selector-body'>
|
||||||
{Array.from({ length: 12 }).map((_, index) => <button className={`item`} key={index} onClick={() => {
|
{Array.from({ length: 12 }).map((_, index) => <button className={`item`} key={index} onClick={() => {
|
||||||
setCurrentMonth(index)
|
setCurrentMonth(index)
|
||||||
|
@ -183,7 +184,8 @@ const SingleDatePicker: React.FC<SingleDatePickerProps> = ({ value, onSelect, lo
|
||||||
{new Date(currentYear, index).toLocaleString(localization || navigator.language, { month: 'long' })}
|
{new Date(currentYear, index).toLocaleString(localization || navigator.language, { month: 'long' })}
|
||||||
</button>)}
|
</button>)}
|
||||||
</div>
|
</div>
|
||||||
{ !!onClose && <button className='sr-only' onClick={onClose}>Close the panel</button> }
|
</div>
|
||||||
|
{!!onClose && <button className='sr-only' onClick={onClose}>Close the panel</button>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
else return (
|
else return (
|
||||||
|
@ -195,6 +197,7 @@ const SingleDatePicker: React.FC<SingleDatePickerProps> = ({ value, onSelect, lo
|
||||||
</button>
|
</button>
|
||||||
<button className='stepper' onClick={skipToNextMonth} aria-label={`Go to next month, ${new Date(currentYear, currentMonth + 1).toLocaleString(localization || navigator.language, { month: 'long' })}`}><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path></svg></button>
|
<button className='stepper' onClick={skipToNextMonth} aria-label={`Go to next month, ${new Date(currentYear, currentMonth + 1).toLocaleString(localization || navigator.language, { month: 'long' })}`}><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path></svg></button>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='body'>
|
||||||
<div className='calendar-view-body grid' aria-live="polite">
|
<div className='calendar-view-body grid' aria-live="polite">
|
||||||
{l10nDays.map((day, index) => <div className='item day-indicator' key={index}>{day}</div>)}
|
{l10nDays.map((day, index) => <div className='item day-indicator' key={index}>{day}</div>)}
|
||||||
|
|
||||||
|
@ -211,7 +214,8 @@ const SingleDatePicker: React.FC<SingleDatePickerProps> = ({ value, onSelect, lo
|
||||||
{date.toDateString() === new Date().toDateString() && <svg xmlns="http://www.w3.org/2000/svg" className='today-indicator' viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"></path></svg>}
|
{date.toDateString() === new Date().toDateString() && <svg xmlns="http://www.w3.org/2000/svg" className='today-indicator' viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"></path></svg>}
|
||||||
</button>)}
|
</button>)}
|
||||||
</div>
|
</div>
|
||||||
{ !!onClose && <button className='sr-only' onClick={onClose}>Close the panel</button> }
|
</div>
|
||||||
|
{!!onClose && <button className='sr-only' onClick={onClose}>Close the panel</button>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,16 @@ export default ({ localization, mainColor = '#000000', accentColor = '#000000',
|
||||||
<button className='stepper' onClick={skipToNextMonth} aria-label={`Go to next month, ${new Date(currentYear, currentMonth + 1).toLocaleString(localization || navigator.language, { month: 'long' })}`}><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path></svg></button>
|
<button className='stepper' onClick={skipToNextMonth} aria-label={`Go to next month, ${new Date(currentYear, currentMonth + 1).toLocaleString(localization || navigator.language, { month: 'long' })}`}><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path></svg></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="body">
|
||||||
|
<div className="week-indicator">
|
||||||
|
<div className="item title">Wk</div>
|
||||||
|
|
||||||
|
{calendarWeeks.map(week => <div className={`item ${selectedWeek.weekNum === calculateWeekNum(week[0]).weekNum && selectedWeek.weekYear === calculateWeekNum(week[0]).weekYear ? 'active' : ''}`} key={calculateWeekNum(week[0]).weekNum} onClick={() => selectWeek(week[0])}>
|
||||||
|
{calculateWeekNum(week[0]).weekNum}
|
||||||
|
</div>)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className='calendar-view-body flex' aria-live="polite">
|
<div className='calendar-view-body flex' aria-live="polite">
|
||||||
<div className="listitem">
|
<div className="listitem">
|
||||||
{Array.from({ length: 7 }).map((_, index) => <div className='item day-indicator' key={index}>{l10nDays[index]}</div>)}
|
{Array.from({ length: 7 }).map((_, index) => <div className='item day-indicator' key={index}>{l10nDays[index]}</div>)}
|
||||||
|
@ -152,5 +162,6 @@ export default ({ localization, mainColor = '#000000', accentColor = '#000000',
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
background: none;
|
background: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--datenel-main-color);
|
color: var(--datenel-main-color);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--datenel-hover-color);
|
background: var(--datenel-hover-color);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.stepper{
|
&.stepper {
|
||||||
width: 1.75rem;
|
width: 1.75rem;
|
||||||
height: 1.75rem;
|
height: 1.75rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -52,27 +53,33 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
input.indicator {
|
input.indicator {
|
||||||
border:none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
outline: none;
|
outline: none;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
padding: 0.25rem 0;
|
padding: 0.25rem 0;
|
||||||
color: var(--datenel-main-color);
|
color: var(--datenel-main-color);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--datenel-hover-color);
|
background: var(--datenel-hover-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.body {
|
||||||
|
display: flex;
|
||||||
.calendar-view-body {
|
.calendar-view-body {
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
gap: 0.125rem;
|
gap: 0.125rem;
|
||||||
&.grid{
|
|
||||||
|
&.grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
|
|
||||||
.item.date {
|
.item.date {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
|
||||||
&.extra-month {
|
&.extra-month {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
@ -83,20 +90,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.flex {
|
&.flex {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.listitem {
|
.listitem {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
|
|
||||||
.item.date {
|
.item.date {
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
background: var(--datenel-accent-color);
|
background: var(--datenel-accent-color);
|
||||||
color: var(--datenel-reversed-color);
|
color: var(--datenel-reversed-color);
|
||||||
|
|
||||||
.extra-month {
|
.extra-month {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
@ -104,6 +116,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
width: 2rem;
|
width: 2rem;
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
|
@ -112,12 +125,15 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&.extra-month {
|
&.extra-month {
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.day-indicator {
|
&.day-indicator {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.today-indicator {
|
.today-indicator {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0.25rem;
|
bottom: 0.25rem;
|
||||||
|
@ -132,9 +148,37 @@
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
gap: 0.125rem;
|
gap: 0.125rem;
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.week-indicator {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
border-right: 1px solid var(--datenel-border-color);
|
||||||
|
gap: 0.125rem;
|
||||||
|
padding: 0.75rem;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
width: 2rem;
|
||||||
|
height: 2rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item.title {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.item.active {
|
||||||
|
background: var(--datenel-accent-color);
|
||||||
|
color: var(--datenel-reversed-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user