Skip to content

Commit

Permalink
feat(VariantManagement): introduce size prop & improve docs (#6166)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcus Notheis <marcus.notheis@sap.com>
  • Loading branch information
Lukas742 and MarcusNotheis authored Aug 6, 2024
1 parent 80c9a65 commit c0184cc
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
display: flex;
align-items: center;
text-align: center;
flex-wrap: nowrap;
}

.title {
cursor: pointer;
color: var(--sapLinkColor);
text-shadow: none;
text-shadow: var(--sapContent_TextShadow);

&:hover {
color: var(--sapLink_Hover_Color);
Expand Down
40 changes: 38 additions & 2 deletions packages/main/src/components/VariantManagement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,42 @@ import type { VariantItemPropTypes } from './VariantItem.js';
import { classNames, styleData } from './VariantManagement.module.css.js';

/**
* The `VariantManagement` component can be used to manage variants, such as FilterBar variants or AnalyticalTable variants.
* The VariantManagement can be used to manage variants (views). You can use this component to create and maintain personalization changes.
*
* __Note:__ On the user interface, variants are generally referred to as "views".
*
* ### Matching header styles
*
* To ensure consistent header styles for different use-cases of the `VariantManagement`, we recommend setting the following styles to the `ui5-title` component:
*
* #### DynamicPage & ObjectPage
*
* - `font-family: var(--sapObjectHeader_Title_FontFamily);`
*
* __Header expanded__
*
* - `font-size: var(--sapObjectHeader_Title_FontSize);`
*
* __Header collapsed/snapped__
*
* - `font-size: var(--sapObjectHeader_Title_SnappedFontSize);`
*
* #### Tables
*
* - `font-size: var(--sapGroup_Title_FontSize);`
*
* #### Example
*
* ```css
* .variantManagement [data-component-name="VariantManagementTitle"] {
* font-family: var(--sapObjectHeader_Title_FontFamily);
* font-size: var(--sapObjectHeader_Title_FontSize);
* }
* ```
* ```jsx
* <VariantManagement className="variantManagement">
* ```
*
*/
const VariantManagement = forwardRef<HTMLDivElement, VariantManagementPropTypes>((props, ref) => {
const i18nBundle = useI18nBundle('@ui5/webcomponents-react');
Expand All @@ -47,6 +82,7 @@ const VariantManagement = forwardRef<HTMLDivElement, VariantManagementPropTypes>
style,
placement = PopoverPlacement.Bottom,
level = TitleLevel.H4,
size = TitleLevel.H4,
onSelect,
closeOnItemSelect,
disabled,
Expand Down Expand Up @@ -292,7 +328,7 @@ const VariantManagement = forwardRef<HTMLDivElement, VariantManagementPropTypes>
}}
>
<FlexBox onClick={disabled ? undefined : handleOpenVariantManagement}>
<Title level={level} className={classNames.title}>
<Title level={level} size={size} className={classNames.title} data-component-name="VariantManagementTitle">
{selectedVariant?.children}
</Title>
{dirtyState && <div className={dirtyStateClasses}>{dirtyStateText}</div>}
Expand Down
14 changes: 13 additions & 1 deletion packages/main/src/components/VariantManagement/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface VariantManagementPropTypes extends Omit<CommonProps, 'onSelect'
children?: ReactNode | ReactNode[];
/**
* Determines on which side the VariantManagement popover is placed at.
*
* @default Bottom
*/
placement?: ResponsivePopoverPropTypes['placement'];
/**
Expand All @@ -39,9 +41,17 @@ export interface VariantManagementPropTypes extends Omit<CommonProps, 'onSelect'
*/
closeOnItemSelect?: boolean;
/**
* Describes the `HTML Title` level of the variants.
* Describes the `Title` HTML level (H1 - H6) of the selected variant. This property doesn't influence the style of the component, you can use the `size` prop for this purpose.
*
* @default H4
*/
level?: TitlePropTypes['level'];
/**
* Describes the `Title`'s `size` of the selected variant.
*
* @default H4
*/
size?: TitlePropTypes['size'];
/**
* Defines whether the VariantManagement is disabled.
*/
Expand All @@ -54,6 +64,8 @@ export interface VariantManagementPropTypes extends Omit<CommonProps, 'onSelect'
dirtyState?: boolean;
/**
* Text for the dirty state indicator.
*
* @default *
*/
dirtyStateText?: string;
/**
Expand Down

0 comments on commit c0184cc

Please sign in to comment.