Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions packages/@react-spectrum/s2/src/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ import {
useSlottedContext
} from 'react-aria-components';
import {AriaCalendarGridProps} from '@react-aria/calendar';
import {baseColor, focusRing, lightDark, style} from '../style' with {type: 'macro'};
import {
CalendarDate,
getDayOfWeek,
startOfMonth
} from '@internationalized/date';
import ChevronLeftIcon from '../s2wf-icons/S2_Icon_ChevronLeft_20_N.svg';
import ChevronRightIcon from '../s2wf-icons/S2_Icon_ChevronRight_20_N.svg';
import {focusRing, lightDark, style} from '../style' with {type: 'macro'};
import {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';
import {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};
import {helpTextStyles} from './Field';
Expand Down Expand Up @@ -156,7 +156,6 @@ const cellInnerStyles = style<CalendarCellRenderProps & {selectionMode: 'single'
},
outlineOffset: {
default: -2,
isToday: 2,
isSelected: {
selectionMode: {
single: 2,
Expand Down Expand Up @@ -184,10 +183,6 @@ const cellInnerStyles = style<CalendarCellRenderProps & {selectionMode: 'single'
},
isPressed: 'gray-100',
isDisabled: 'transparent',
isToday: {
default: baseColor('gray-300'),
isDisabled: 'disabled'
},
isSelected: {
selectionMode: {
single: {
Expand Down Expand Up @@ -254,7 +249,6 @@ const cellInnerStyles = style<CalendarCellRenderProps & {selectionMode: 'single'
},
forcedColors: {
default: 'transparent',
isToday: 'ButtonFace',
isHovered: 'Highlight',
isSelected: {
selectionMode: {
Expand Down Expand Up @@ -282,7 +276,6 @@ const cellInnerStyles = style<CalendarCellRenderProps & {selectionMode: 'single'
isDisabled: 'disabled',
forcedColors: {
default: 'ButtonText',
isToday: 'ButtonFace',
isSelected: 'HighlightText',
isSelectionStart: 'HighlightText',
isSelectionEnd: 'HighlightText',
Expand All @@ -291,6 +284,21 @@ const cellInnerStyles = style<CalendarCellRenderProps & {selectionMode: 'single'
}
});

const todayStyles = style({
position: 'absolute',
bottom: 4,
left: '50%',
transform: 'translateX(-50%)',
width: 4,
height: 4,
borderRadius: 'full',
backgroundColor: '[currentColor]',
display: {
default: 'none',
isToday: 'block'
}
});

const unavailableStyles = style({
position: 'absolute',
top: 'calc(50% - 1px)',
Expand All @@ -309,8 +317,8 @@ const selectionSpanStyles = style<{isInvalid?: boolean}>({
insetStart: 'calc(-1 * var(--selection-span) * (var(--cell-width) + var(--cell-gap) + var(--cell-gap)))',
insetEnd: 0,
bottom: 0,
borderWidth: 2,
borderStyle: 'dashed',
borderWidth: 1,
borderStyle: 'solid',
borderColor: {
default: 'blue-800', // focus-indicator-color
isInvalid: 'negative-900',
Expand Down Expand Up @@ -592,6 +600,7 @@ const CalendarCellInner = (props: Omit<CalendarCellProps, 'children'> & {isRange
ref={ref}
style={pressScale(ref, {})(renderProps!)}
className={cellInnerStyles({...renderProps!, isSelectionStart, isSelectionEnd, selectionMode: isRangeSelection ? 'range' : 'single'})}>
<div className={todayStyles(renderProps!)} role="presentation" />
<div>
{formattedDate}
</div>
Expand Down