diff --git a/docs/MigrationGuide.mdx b/docs/MigrationGuide.mdx index ff09b30ed5a..09378002193 100644 --- a/docs/MigrationGuide.mdx +++ b/docs/MigrationGuide.mdx @@ -38,6 +38,15 @@ function MyRootComponent() { } ``` +### Scrollbar Styling + +Starting with v2, the `ThemeProvider` will apply the Fiori styles to all scrollbars on the page. +If you have previously used our global style classes `sapScrollBar` or `inheritingSapScrollBar`, you can now remove them. + +To opt-out of this behavior, you can add the `.ui5-content-native-scrollbars` class to the element to prevent the scrollbar styling from being applied. + +More details can be found in our [Styling Knowledge Base](?path=/docs/knowledge-base-styling--docs#scrollbars). + ## Removed hooks ### `useResponsiveContentPadding` diff --git a/docs/knowledge-base/Styling.mdx b/docs/knowledge-base/Styling.mdx index dc6732a54c7..499fa40f68e 100644 --- a/docs/knowledge-base/Styling.mdx +++ b/docs/knowledge-base/Styling.mdx @@ -37,26 +37,20 @@ You can change CSS Variables on any level - in the head, or on every single elem A full list of all supported CSS Variables can be found [here](https://github.com/SAP/ui5-webcomponents-react/blob/main/packages/base/src/styling/ThemingParameters.ts) or in the [theming-base-content](https://github.com/SAP/theming-base-content/tree/master/content/Base/baseLib) repo. -## Reuse global style classes +## Scrollbars -The `ThemeProvider` component is offering global css classes that can be reused in your applications code to help you to achieve a Fiori look-and-feel. -All globally available style classes are tracked in the `GlobalStyleClasses` enum which can be imported from `import { GlobalStyleClasses } from "@ui5/webcomponents-react";`. - -| CSS Class | Description | -| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | -| `sapScrollBar` | If added to an container that supports scrolling, the scrollbar will be styled according to Fiori guidelines. | -| `inheritingSapScrollBar` | If added to a container, the scollbars of the container and of all of its children will be styled according to Fiori guidelines. | +Rendering our `ThemeProvider` will apply the Fiori styles to all scrollbars on the page. +If you want to opt-out of this behavior, you can add the `.ui5-content-native-scrollbars` class to the respective element to prevent the scrollbar styling from being applied. -### Use default browser scrollbar - -Some components like the `ObjectPage`, `DynamicPage` and `AnalyticalTable` use the CSS class `sapScrollBar` by default. To prevent components from using the custom scrollbar, you can pass `data-native-scrollbar` as prop. +```tsx +{children} +``` ## Style your own components diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index 0b7d73ec1af..2c571bc808d 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -31,8 +31,7 @@ import { AnalyticalTableSelectionBehavior, AnalyticalTableSelectionMode, AnalyticalTableSubComponentsBehavior, - AnalyticalTableVisibleRowCountMode, - GlobalStyleClasses + AnalyticalTableVisibleRowCountMode } from '../../enums/index.js'; import { COLLAPSE_NODE, @@ -655,9 +654,9 @@ const AnalyticalTable = forwardRef { @@ -746,7 +745,6 @@ const AnalyticalTable = forwardRef
@@ -837,9 +835,9 @@ const AnalyticalTable = forwardRef )} diff --git a/packages/main/src/components/AnalyticalTable/scrollbars/VerticalScrollbar.tsx b/packages/main/src/components/AnalyticalTable/scrollbars/VerticalScrollbar.tsx index 0963824b132..801fe6acbc8 100644 --- a/packages/main/src/components/AnalyticalTable/scrollbars/VerticalScrollbar.tsx +++ b/packages/main/src/components/AnalyticalTable/scrollbars/VerticalScrollbar.tsx @@ -2,7 +2,7 @@ import { ThemingParameters, useStylesheet, useSyncRef } from '@ui5/webcomponents import { clsx } from 'clsx'; import type { MutableRefObject, RefObject } from 'react'; import { forwardRef, useEffect, useRef } from 'react'; -import { FlexBoxDirection, GlobalStyleClasses } from '../../../enums/index.js'; +import { FlexBoxDirection } from '../../../enums/index.js'; import { FlexBox } from '../../FlexBox/index.js'; import { classNames, styleData } from './VerticalScrollbar.module.css.js'; @@ -11,14 +11,21 @@ interface VerticalScrollbarProps { tableRef: RefObject; handleVerticalScrollBarScroll: any; tableBodyHeight: number; - 'data-native-scrollbar'?: any; scrollContainerRef: MutableRefObject; parentRef: MutableRefObject; + nativeScrollbar: boolean; } export const VerticalScrollbar = forwardRef((props, ref) => { - const { internalRowHeight, tableRef, handleVerticalScrollBarScroll, tableBodyHeight, scrollContainerRef, parentRef } = - props; + const { + internalRowHeight, + tableRef, + handleVerticalScrollBarScroll, + tableBodyHeight, + scrollContainerRef, + nativeScrollbar, + parentRef + } = props; const [componentRef, containerRef] = useSyncRef(ref); const scrollElementRef = useRef(null); useStylesheet(styleData, VerticalScrollbar.displayName); @@ -58,8 +65,7 @@ export const VerticalScrollbar = forwardRef
((props, setListFilter(e.detail.selectedItems.at(0).dataset.key as never); }; - const outerClasses = clsx( - classNames.container, - GlobalStyleClasses.sapScrollBar, - className, - selectedMessage && classNames.showDetails - ); + const outerClasses = clsx(classNames.container, className, selectedMessage && classNames.showDetails); return (
diff --git a/packages/main/src/components/ObjectPage/index.tsx b/packages/main/src/components/ObjectPage/index.tsx index 6f47bf6ae34..ff9fec55e72 100644 --- a/packages/main/src/components/ObjectPage/index.tsx +++ b/packages/main/src/components/ObjectPage/index.tsx @@ -13,7 +13,7 @@ import { import { clsx } from 'clsx'; import type { CSSProperties, ReactElement, ReactNode } from 'react'; import { cloneElement, forwardRef, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { GlobalStyleClasses, ObjectPageMode } from '../../enums/index.js'; +import { ObjectPageMode } from '../../enums/index.js'; import { addCustomCSSWithScoping } from '../../internal/addCustomCSSWithScoping.js'; import { safeGetChildrenArray } from '../../internal/safeGetChildrenArray.js'; import { useObserveHeights } from '../../internal/useObserveHeights.js'; @@ -549,7 +549,6 @@ const ObjectPage = forwardRef((props, ref) const objectPageClasses = clsx( classNames.objectPage, - GlobalStyleClasses.sapScrollBar, className, mode === ObjectPageMode.IconTabBar && classNames.iconTabBarMode ); diff --git a/packages/main/src/components/ThemeProvider/ThemeProvider.css b/packages/main/src/components/ThemeProvider/ThemeProvider.css index 41623eb5629..87e7294af35 100644 --- a/packages/main/src/components/ThemeProvider/ThemeProvider.css +++ b/packages/main/src/components/ThemeProvider/ThemeProvider.css @@ -14,7 +14,7 @@ @import '../../themes/sap_horizon_hcb.css'; @import '../../themes/sap_horizon_hcw.css'; -.inheritingSapScrollBar *:not([data-native-scrollbar]) { +:not(.ui5-content-native-scrollbars) { &::-webkit-scrollbar { background-color: var(--sapScrollBar_TrackColor); -webkit-border-start: var(--_ui5wcr_Scrollbar_Border); @@ -49,41 +49,3 @@ width: var(--sapScrollBar_Dimension); } } - -.sapScrollBar:not([data-native-scrollbar]) { - &::-webkit-scrollbar { - background-color: var(--sapScrollBar_TrackColor); - -webkit-border-start: var(--_ui5wcr_Scrollbar_Border); - } - - &::-webkit-scrollbar-thumb { - border-radius: var(--_ui5wcr_Scrollbar_BorderRadius); - background-color: var(--sapScrollBar_FaceColor); - } - - &::-webkit-scrollbar-corner { - background-color: var(--sapScrollBar_TrackColor); - } - - &::-webkit-scrollbar-thumb { - &:hover { - background-color: var(--sapScrollBar_Hover_FaceColor); - } - - &:horizontal { - height: var(--sapScrollBar_Dimension); - } - - &:vertical { - width: var(--sapScrollBar_Dimension); - } - } - - &::-webkit-scrollbar:horizontal { - height: var(--sapScrollBar_Dimension); - } - - &::-webkit-scrollbar:vertical { - width: var(--sapScrollBar_Dimension); - } -} diff --git a/packages/main/src/enums/GlobalStyleClasses.ts b/packages/main/src/enums/GlobalStyleClasses.ts deleted file mode 100644 index 310f4622583..00000000000 --- a/packages/main/src/enums/GlobalStyleClasses.ts +++ /dev/null @@ -1,10 +0,0 @@ -export enum GlobalStyleClasses { - /** - * The scrollbar of the element to which the class is applied is styled according to Fiori guidelines. - */ - sapScrollBar = 'sapScrollBar', - /** - * The scrollbar of the element to which the class is applied and all of its children are styled according to Fiori guidelines. - */ - inheritingSapScrollBar = 'inheritingSapScrollBar' -} diff --git a/packages/main/src/enums/index.ts b/packages/main/src/enums/index.ts index 245dd619fdf..144b5a68f8a 100644 --- a/packages/main/src/enums/index.ts +++ b/packages/main/src/enums/index.ts @@ -13,7 +13,6 @@ export * from './FlexBoxAlignItems.js'; export * from './FlexBoxDirection.js'; export * from './FlexBoxJustifyContent.js'; export * from './FlexBoxWrap.js'; -export * from './GlobalStyleClasses.js'; export * from './GridPosition.js'; export * from './IndicationColor.js'; export * from './LoaderType.js';