Skip to content

Commit f96482b

Browse files
refactor(ActionSheet): migrate to css module (#5532)
1 parent 5d911e2 commit f96482b

File tree

3 files changed

+44
-52
lines changed

3 files changed

+44
-52
lines changed

packages/main/src/components/ActionSheet/ActionSheet.jss.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.actionSheet::part(content) {
2+
padding: 0.1875rem 0.375rem;
3+
}
4+
5+
.actionSheet [ui5-button] {
6+
margin: var(--_ui5wcr-ButtonTopBottomPadding);
7+
display: block;
8+
}
9+
10+
.actionSheet [ui5-button]:not([data-cancel-btn])::part(button) {
11+
justify-content: start;
12+
}
13+
14+
.actionSheet::part(header) {
15+
background: transparent;
16+
box-shadow: var(--_ui5wcr_ActionSheet_HeaderBoxShadow);
17+
}
18+
19+
/* actionSheetMobile */
20+
.actionSheetMobile::part(content) {
21+
padding: 0 !important;
22+
}
23+
24+
/* contentMobile */
25+
.contentMobile {
26+
background-color: var(--sapGroup_ContentBackground);
27+
padding: 0.25rem 0.5rem;
28+
box-sizing: border-box;
29+
overflow: auto;
30+
max-height: 82vh;
31+
border-top-left-radius: var(--_ui5wcr_ActionSheet_TopBorderRadius);
32+
border-top-right-radius: var(--_ui5wcr_ActionSheet_TopBorderRadius);
33+
box-shadow: var(--_ui5wcr_ActionSheet_BoxShadow);
34+
}
35+
36+
.contentMobile > * {
37+
margin: 0.25rem 0;
38+
}

packages/main/src/components/ActionSheet/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
'use client';
22

33
import { isPhone } from '@ui5/webcomponents-base/dist/Device.js';
4-
import { useI18nBundle, useSyncRef } from '@ui5/webcomponents-react-base';
4+
import { useI18nBundle, useStylesheet, useSyncRef } from '@ui5/webcomponents-react-base';
55
import { clsx } from 'clsx';
66
import type { ReactElement } from 'react';
77
import React, { forwardRef, useReducer, useRef } from 'react';
88
import { createPortal } from 'react-dom';
9-
import { createUseStyles } from 'react-jss';
109
import { ButtonDesign } from '../../enums/index.js';
1110
import { AVAILABLE_ACTIONS, CANCEL, X_OF_Y } from '../../i18n/i18n-defaults.js';
1211
import { addCustomCSSWithScoping } from '../../internal/addCustomCSSWithScoping.js';
@@ -20,7 +19,7 @@ import type {
2019
ResponsivePopoverPropTypes
2120
} from '../../webComponents/index.js';
2221
import { Button, ResponsivePopover } from '../../webComponents/index.js';
23-
import styles from './ActionSheet.jss.js';
22+
import { classNames, styleData } from './ActionSheet.module.css.js';
2423

2524
export interface ActionSheetPropTypes extends Omit<ResponsivePopoverPropTypes, 'header' | 'headerText' | 'children'> {
2625
/**
@@ -64,8 +63,6 @@ export interface ActionSheetPropTypes extends Omit<ResponsivePopoverPropTypes, '
6463
portalContainer?: Element;
6564
}
6665

67-
const useStyles = createUseStyles(styles, { name: 'ActionSheet' });
68-
6966
if (isPhone()) {
7067
addCustomCSSWithScoping(
7168
'ui5-responsive-popover',
@@ -154,8 +151,9 @@ const ActionSheet = forwardRef<ResponsivePopoverDomRef, ActionSheetPropTypes>((p
154151
...rest
155152
} = props;
156153

154+
useStylesheet(styleData, ActionSheet.displayName);
155+
157156
const i18nBundle = useI18nBundle('@ui5/webcomponents-react');
158-
const classes = useStyles();
159157
const [componentRef, popoverRef] = useSyncRef(ref);
160158
const actionBtnsRef = useRef(null);
161159
const [focusedItem, setFocusedItem] = useReducer((_, action) => {
@@ -268,11 +266,11 @@ const ActionSheet = forwardRef<ResponsivePopoverDomRef, ActionSheetPropTypes>((p
268266
{...rest}
269267
onAfterOpen={handleAfterOpen}
270268
ref={componentRef}
271-
className={clsx(classes.actionSheet, isPhone() && classes.actionSheetMobile, className)}
269+
className={clsx(classNames.actionSheet, isPhone() && classNames.actionSheetMobile, className)}
272270
data-actionsheet
273271
>
274272
<div
275-
className={isPhone() ? classes.contentMobile : undefined}
273+
className={isPhone() ? classNames.contentMobile : undefined}
276274
data-component-name="ActionSheetMobileContent"
277275
role={a11yConfig?.actionSheetMobileContent?.role ?? 'application'}
278276
onKeyDown={handleKeyDown}

0 commit comments

Comments
 (0)