Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove all spacing variables #6009

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
86 changes: 86 additions & 0 deletions docs/MigrationGuide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,92 @@ To opt-out of this behavior, you can add the `.ui5-content-native-scrollbars` cl

More details can be found in our [Styling Knowledge Base](?path=/docs/knowledge-base-styling--docs#scrollbars).

## Spacing

The `spacing` variables of our base package (`@ui5/webcomponents-react-base`) have been removed.
Most variables can be replaced by applying the corresponding CSS classes from the `@sap-ui/common-css` package to your element, for all others you can find the respective CSS properties and values below.

**Full Documentation of Common CSS classes:**

- [Margins](https://sap.github.io/fundamental-styles/?path=/docs/common-css-margins--docs)
- [Paddings](https://sap.github.io/fundamental-styles/?path=/docs/common-css-padding--docs)

### Common CSS substitute classes

<details>
<summary>Show</summary>

| Removed Variable | Equivalent Common CSS Class |
| ----------------------------------- | ----------------------------- |
| **All Around Margins** | |
| `sapUiTinyMargin` | `.sap-margin-tiny` |
| `sapUiSmallMargin` | `.sap-margin-small` |
| `sapUiMediumMargin` | `.sap-margin-medium` |
| `sapUiLargeMargin` | `.sap-margin-large` |
| `sapUiTinyMargin` | `.sap-margin-tiny` |
| `sapUiTinyMargin` | `.sap-margin-tiny` |
Lukas742 marked this conversation as resolved.
Show resolved Hide resolved
| **Single Side Margins** | |
| `sapUiTinyMarginTop` | `.sap-margin-top-tiny` |
| `sapUiSmallMarginTop` | `.sap-margin-top-small` |
| `sapUiMediumMarginTop` | `.sap-margin-top-medium` |
| `sapUiLargeMarginTop` | `.sap-margin-top-large` |
| `sapUiTinyMarginBottom` | `.sap-margin-bottom-tiny` |
| `sapUiSmallMarginBottom` | `.sap-margin-bottom-small` |
| `sapUiMediumMarginBottom` | `.sap-margin-bottom-medium` |
| `sapUiLargeMarginBottom` | `.sap-margin-bottom-large` |
| `sapUiTinyMarginBegin` | `.sap-margin-begin-tiny` |
| `sapUiSmallMarginBegin` | `.sap-margin-begin-small` |
| `sapUiMediumMarginBegin` | `.sap-margin-begin-medium` |
| `sapUiLargeMarginBegin` | `.sap-margin-begin-large` |
| `sapUiTinyMarginEnd` | `.sap-margin-end-tiny` |
| `sapUiSmallMarginEnd` | `.sap-margin-end-small` |
| `sapUiMediumMarginEnd` | `.sap-margin-end-medium` |
| `sapUiLargeMarginEnd` | `.sap-margin-end-large` |
| **Horizontal Margins** | |
| `sapUiTinyMarginBeginEnd` | `.sap-margin-x-tiny` |
| `sapUiSmallMarginBeginEnd` | `.sap-margin-x-small` |
| `sapUiMediumMarginBeginEnd` | `.sap-margin-x-medium` |
| `sapUiLargeMarginBeginEnd` | `.sap-margin-x-large` |
| **Vertical Margins** | |
| `sapUiTinyMarginTopBottom` | `.sap-margin-y-tiny` |
| `sapUiSmallMarginBeginEnd` | `.sap-margin-y-small` |
| `sapUiMediumMarginTopBottom` | `.sap-margin-y-medium` |
| `sapUiLargeMarginTopBottom` | `.sap-margin-y-large` |
| **Responsive Margins** | |
| `sapUiResponsiveMargin` | `.sap-margin-responsive` |
| **Negative Margins** | |
| `sapUiTinyNegativeMarginBeginEnd` | `.sap-margin-tiny-negative` |
| `sapUiSmallNegativeMarginBeginEnd` | `.sap-margin-small-negative` |
| `sapUiMediumNegativeMarginBeginEnd` | `.sap-margin-medium-negative` |
| `sapUiLargeNegativeMarginBeginEnd` | `.sap-margin-large-negative` |
| **All Around Padding** | |
| `sapUiContentPadding` | `.sap-padding` |
| **Responsive Paddings** | |
| `sapUiResponsiveContentPadding` | `.sap-padding-responsive` |
| **Horizontal Paddings** | |
| `sapUiTinyPaddingBeginEnd` | `.sap-padding-x-tiny` |
| `sapUiSmallPaddingBeginEnd` | `.sap-padding-x-small` |
| `sapUiMediumPaddingBeginEnd` | `.sap-padding-x-medium` |
| `sapUiLargePaddingBeginEnd` | `.sap-padding-x-large` |
| **No Padding** | |
| `sapUiNoContentPadding` | `.sap-padding-none` |

</details>

### Removed variables without substitute

<details>
<summary>Show</summary>

| Removed Variable | Property and Value |
| --------------------- | ------------------------------ |
| `sapUiNoMargin` | `margin: 0 !important;` |
| `sapUiNoMarginTop` | `margin-top: 0 !important;` |
| `sapUiNoMarginBottom` | `margin-bottom: 0 !important;` |
| `sapUiForceWidthAuto` | `width: auto !important;` |

</details>

## Removed hooks

### `useResponsiveContentPadding`
Expand Down
23 changes: 20 additions & 3 deletions docs/knowledge-base/CommonCSS.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,26 @@ import '@sap-ui/common-css/dist/sap-content-paddings.css';

You can apply a dynamic content padding for your element by applying the following classes to your HTML:

```html
<div class="sap-container-type-inline-size">
<div class="sap-content-paddings-container">I will have a responsive content padding</div>
```jsx
<div className="sap-container-type-inline-size">
<div className="sap-content-paddings-container">I will have a responsive content padding</div>
</div>
```

## Margins & Paddings

Common CSS is offering classes that you can use to create some spacing between elements.

**Full Documentation:**

- [Margins](https://sap.github.io/fundamental-styles/?path=/docs/common-css-margins--docs)
- [Paddings](https://sap.github.io/fundamental-styles/?path=/docs/common-css-padding--docs)

```jsx
<div className="sap-padding-x-small">
<button className=".sap-margin-begin-small">Start Button</button>
Lukas742 marked this conversation as resolved.
Show resolved Hide resolved
<button className=".sap-margin-x-small">Mid Button</button>
Lukas742 marked this conversation as resolved.
Show resolved Hide resolved
<button className=".sap-margin-end-small">End Button</button>
Lukas742 marked this conversation as resolved.
Show resolved Hide resolved
</div>
```

Expand Down
8 changes: 0 additions & 8 deletions docs/knowledge-base/Public-Utils.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ background color for your current theme.

<ThemeableCSSVars />

## Spacing

<Source code={`import { spacing } from '@ui5/webcomponents-react-base';`} />

The `spacing` file is containing all standard margins and paddings that are used in SAP Applications.
You can explore them via the [UI5 Standard Margins Demo Kit](https://ui5.sap.com/#/entity/sap.ui.core.StandardMargins)
and the [UI5 Standard Paddings Demo Kit](https://ui5.sap.com/#/entity/sap.ui.core.ContainerPadding).

## Hooks

### `useI18nBundle`
Expand Down
3 changes: 1 addition & 2 deletions packages/base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { getI18nContext, I18nContext } from './context/I18nContext.js';
import * as Device from './Device/index.js';
import * as hooks from './hooks/index.js';
import { StyleStore } from './stores/StyleStore.js';
import * as spacing from './styling/spacing.js';
import { ThemingParameters } from './styling/ThemingParameters.js';

export * from './styling/CssSizeVariables.js';
export * from './utils/index.js';
export * from './hooks/index.js';

export { getI18nContext, I18nContext, StyleStore, ThemingParameters, Device, hooks, spacing };
export { getI18nContext, I18nContext, StyleStore, ThemingParameters, Device, hooks };
231 changes: 0 additions & 231 deletions packages/base/src/styling/spacing.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/main/src/components/Loader/Loader.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react';
import activateIcon from '@ui5/webcomponents-icons/dist/activate.js';
import { spacing } from '@ui5/webcomponents-react-base';
import { useEffect, useRef, useState } from 'react';
import { FlexBoxDirection, LoaderType } from '../../enums/index.js';
import { Card } from '../../webComponents/Card/index.js';
Expand Down Expand Up @@ -62,7 +61,7 @@ export const WithCard: Story = {
>
<FlexBox direction={FlexBoxDirection.Column}>
{loading && <Loader {...args} />}
<Text style={spacing.sapUiContentPadding}>{text}</Text>
<Text style={{ padding: '1rem' }}>{text}</Text>
</FlexBox>
</Card>
);
Expand Down
Loading
Loading