Skip to content

Commit

Permalink
fix: after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mshatikhin committed Jun 28, 2024
1 parent 4da3a41 commit d0c90ae
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export const getStyles = (emotion: Emotion) =>
width: ${t.inputWidth};
`;
},
noPortal() {
return css`

noPortal() {
return emotion.css`
position: relative;
`;
},
},
});
6 changes: 4 additions & 2 deletions packages/react-ui/components/Calendar/CalendarDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React, { PropsWithChildren, useContext, memo } from 'react';

import { useLocaleForControl } from '../../lib/locale/useLocaleForControl';
import { ThemeContext } from '../../lib/theming/ThemeContext';
import { cx } from '../../lib/theming/Emotion';
import { cx, useEmotion } from '../../lib/theming/Emotion';
import { isTheme2022 } from '../../lib/theming/ThemeHelpers';
import { DatePickerLocaleHelper } from '../DatePicker/locale';
import { InternalDate } from '../../lib/date/InternalDate';
import { LocaleContext } from '../../lib/locale';
import { getVisualStateDataAttributes } from '../../internal/CommonWrapper/utils/getVisualStateDataAttributes';
import { forwardRefAndName } from '../../lib/forwardRefAndName';

import { styles } from './DayCellView.styles';
import { getStyles } from './DayCellView.styles';
import { CalendarDataTids } from './Calendar';

export interface CalendarDayProps extends React.HTMLAttributes<HTMLButtonElement> {
Expand Down Expand Up @@ -41,6 +41,7 @@ export const CalendarDay = memo(
ref: React.Ref<HTMLButtonElement>,
) {
const theme = useContext(ThemeContext);
const emotion = useEmotion();
const _isTheme2022 = isTheme2022(theme);

const { langCode } = useContext(LocaleContext);
Expand All @@ -51,6 +52,7 @@ export const CalendarDay = memo(

const { date: day } = internalDate.getComponentsLikeNumber();
const caption = children ?? day;
const styles = getStyles(emotion);

return (
<button
Expand Down
22 changes: 11 additions & 11 deletions packages/react-ui/components/Calendar/DayCellView.styles.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { css, memoizeStyle } from '../../lib/theming/Emotion';
import type { Emotion } from '@emotion/css/create-instance';

import { memoizeStyle, prefix } from '../../lib/theming/Emotion';
import { memoizeStyle } from '../../lib/theming/Emotion';
import { Theme } from '../../lib/theming/Theme';
import { resetButton } from '../../lib/styles/Mixins';

export const getStyles = (emotion: Emotion) =>
memoizeStyle({
export const getStyles = (emotion: Emotion) => {
return memoizeStyle({
cell(t: Theme) {
return emotion.css`
flex: 1 1 ${t.calendarCellWidth};
height: ${t.calendarCellHeight};
`;
},
day(t: Theme) {
return css`
width: 100%;
height: 100%;
},

day(t: Theme) {
return emotion.css`
width: 100%;
height: 100%;
background: ${t.calendarCellBg};
border: 1px solid transparent;
Expand Down Expand Up @@ -62,10 +61,11 @@ export const getStyles = (emotion: Emotion) =>
`;
},

todayCaption2022(t: Theme) {
todayCaption2022(t: Theme) {
return emotion.css`
padding-bottom: 2px;
border-bottom: ${t.calendarCellTodayBorder};
`;
},
});
};
4 changes: 2 additions & 2 deletions packages/react-ui/components/Calendar/DayCellView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import React, { useContext } from 'react';

import { useEmotion } from '../../lib/theming/Emotion';
import { InternalDateTransformer } from '../../lib/date/InternalDateTransformer';
import { useTheme } from '../../lib/theming/useTheme';

import { styles } from './DayCellView.styles';
import { getStyles } from './DayCellView.styles';
import { CalendarContext } from './CalendarContext';
import { DayCellViewModel } from './DayCellViewModel';
import * as CDS from './CalendarDateShape';
Expand Down
3 changes: 2 additions & 1 deletion packages/react-ui/components/Calendar/Month.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MonthView } from './MonthView';
import { DayCellView } from './DayCellView';
import * as CalendarScrollEvents from './CalendarScrollEvents';
import { getStyles } from './MonthView.styles';
import { styles as cellStyles } from './DayCellView.styles';
import { getStyles as getCellStyles } from './DayCellView.styles';

interface MonthProps {
top: number;
Expand Down Expand Up @@ -134,6 +134,7 @@ class MonthDayGrid extends React.Component<MonthDayGridProps> {

public renderMain() {
const styles = getStyles(this.emotion);
const cellStyles = getCellStyles(this.emotion);
const leadingDays = Array.from({ length: this.props.offset }, (_, i) => (
<div key={`leading_${i}`} className={cellStyles.cell(this.theme)} />
));
Expand Down
30 changes: 15 additions & 15 deletions packages/react-ui/components/Calendar/MonthView.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export const getStyles = (emotion: Emotion) =>
`;
},

monthMobile() {
return css`
width: 100%;
`;
},
monthMobile() {
return emotion.css`
width: 100%;
`;
},

header() {
return emotion.css`
Expand All @@ -57,32 +57,32 @@ export const getStyles = (emotion: Emotion) =>
`;
},

/* Note: this could've been
* display: grid;
* grid-template-columns: repeat(7, minmax(0, 1fr));
*/
/* Note: this could've been
* display: grid;
* grid-template-columns: repeat(7, minmax(0, 1fr));
*/
monthDayGrid(t: Theme) {
return emotion.css`
line-height: ${t.calendarCellLineHeight};
display: flex;
flex-direction: column;
padding: ${t.calendarGridRowSpacing} 0px;
`;
},
},

monthDayRow(t: Theme) {
return css`
monthDayRow(t: Theme) {
return emotion.css`
display: flex;
justify-content: space-between;
& + & {
margin-top: ${t.calendarGridRowSpacing};
}
`;
},
},

nativeSelect() {
return css`
nativeSelect() {
return emotion.css`
position: absolute;
top: -12px;
right: 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-ui/components/Calendar/MonthView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';

import { DateSelect } from '../../internal/DateSelect';
import * as ColorFunctions from '../../lib/styles/ColorFunctions';
Expand Down Expand Up @@ -84,7 +84,7 @@ export function MonthView(props: MonthViewProps) {
return (
<div
data-tid={CalendarDataTids.month}
className={cx({ [styles.month(theme)]: true, [styles.monthMobile()]: isMobile })}
className={emotion.cx({ [styles.month(theme)]: true, [styles.monthMobile()]: isMobile })}
style={{ top }}
key={month + '-' + year}
>
Expand Down
6 changes: 3 additions & 3 deletions packages/react-ui/internal/DateSelect/DateSelect.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ export const getStyles = (emotion: Emotion) =>
`;
},

nativeSelect() {
return css`
nativeSelect() {
return emotion.css`
position: absolute;
top: -12px;
right: 0;
Expand All @@ -204,5 +204,5 @@ export const getStyles = (emotion: Emotion) =>
opacity: 0;
border: none;
`;
},
},
});
1 change: 1 addition & 0 deletions packages/react-ui/internal/DateSelect/DateSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ export class DateSelect extends React.PureComponent<DateSelectProps, DateSelectS
for (let item = from; item <= to; ++item) {
items.push({ item, disabled: item < min || item > max });
}
const styles = getStyles(this.emotion);

return (
// eslint-disable-next-line jsx-a11y/no-onchange
Expand Down

0 comments on commit d0c90ae

Please sign in to comment.