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

feat(Section): add dropShadow support #3053

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const ResponsiveAppearance = () => (
medium: 'pistachio',
large: 'pistachio',
}}
dropShadow={{
small: false,
medium: true,
large: true,
}}
innerSpace
>
<P space={0}>Responsive properties</P>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Where `innerSpace` do respond on different screen sizes.

### Responsive appearance

Where `breakout`, `outline`, `roundedCorner` and `backgroundColor` do respond on different screen sizes.
Where `breakout`, `outline`, `roundedCorner`, `backgroundColor` and `dropShadow` do respond on different screen sizes.

<Examples.ResponsiveAppearance />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ showTabs: true
| `outline` | _(optional)_ define a custom border color. If `true` is given, `color-black-8` is used. Use a Eufemia [color](/uilib/usage/customisation/colors/). Supports also media query breakpoints like `{ small: 'black-8' }` |
| `roundedCorner` | _(optional)_ use `true` to enable rounded corners (border-radius). Supports also media query breakpoints like `{ small: boolean }`. Defaults to `false`. |
| `backgroundColor` | _(optional)_ define a custom background color, instead of a variant. Use a Eufemia [color](/uilib/usage/customisation/colors/). Supports also media query breakpoints like `{ small: 'white' }`. |
| `dropShadow` | _(optional)_ use `true` to show the default Eufemia DropShadow. Supports also media query breakpoints like `{ small: true }`. |
| `textColor` | _(optional)_ define a custom text color to compliment the backgroundColor. Use a Eufemia [color](/uilib/usage/customisation/colors/). Supports also media query breakpoints like `{ small: 'black-80' }`. |
| `innerSpace` | _(optional)_ will add a padding around the content. Supports also media query breakpoints like `{small: { top: 'medium' }}`. |
| `innerRef` | _(optional)_ by providing a React Ref we can get the internally used element (DOM). E.g. `inner_ref={myRef}` by using `React.createRef()` or `React.useRef()`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,12 @@ button.dnb-button::-moz-focus-inner {
.dnb-section[style*="--background-color"] {
background-color: var(--background-color, white);
}
.dnb-section::before {
content: "";
position: absolute;
inset: 0;
box-shadow: var(--drop-shadow, none);
}
.dnb-section::after {
content: "";
visibility: var(--breakout, hidden);
Expand All @@ -618,6 +624,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--small);
--text-color--value: var(--text-color--small);
--outline-color: var(--outline-color--small);
--drop-shadow: var(--drop-shadow--small);
--rounded-corner: var(
--rounded-corner--small,
var(--rounded-corner--fallback)
Expand All @@ -630,6 +637,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--medium);
--text-color--value: var(--text-color--medium);
--outline-color: var(--outline-color--medium);
--drop-shadow: var(--drop-shadow--medium);
--rounded-corner: var(
--rounded-corner--medium,
var(--rounded-corner--fallback)
Expand All @@ -642,6 +650,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--large);
--text-color--value: var(--text-color--large);
--outline-color: var(--outline-color--large);
--drop-shadow: var(--drop-shadow--large);
--rounded-corner: var(
--rounded-corner--large,
var(--rounded-corner--fallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,12 @@ button.dnb-button::-moz-focus-inner {
.dnb-section[style*="--background-color"] {
background-color: var(--background-color, white);
}
.dnb-section::before {
content: "";
position: absolute;
inset: 0;
box-shadow: var(--drop-shadow, none);
}
.dnb-section::after {
content: "";
visibility: var(--breakout, hidden);
Expand All @@ -618,6 +624,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--small);
--text-color--value: var(--text-color--small);
--outline-color: var(--outline-color--small);
--drop-shadow: var(--drop-shadow--small);
--rounded-corner: var(
--rounded-corner--small,
var(--rounded-corner--fallback)
Expand All @@ -630,6 +637,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--medium);
--text-color--value: var(--text-color--medium);
--outline-color: var(--outline-color--medium);
--drop-shadow: var(--drop-shadow--medium);
--rounded-corner: var(
--rounded-corner--medium,
var(--rounded-corner--fallback)
Expand All @@ -642,6 +650,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--large);
--text-color--value: var(--text-color--large);
--outline-color: var(--outline-color--large);
--drop-shadow: var(--drop-shadow--large);
--rounded-corner: var(
--rounded-corner--large,
var(--rounded-corner--fallback)
Expand Down
12 changes: 12 additions & 0 deletions packages/dnb-eufemia/src/components/section/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export type SectionSpacing =
export type TextColor = string
export type OutlineColor = string | boolean
export type BackgroundColor = string
export type DropShadow = boolean

export type SectionProps = {
/**
Expand Down Expand Up @@ -89,6 +90,11 @@ export type SectionProps = {
*/
backgroundColor?: BackgroundColor | ResponsiveProp<BackgroundColor>

/**
* Define a custom drop-shadow.
*/
dropShadow?: DropShadow | ResponsiveProp<DropShadow>

/**
* Define what HTML element should be used. Defaults to `<section>`.
*/
Expand Down Expand Up @@ -137,6 +143,7 @@ export default function Section(localProps: SectionAllProps) {
roundedCorner,
textColor,
backgroundColor,
dropShadow,
outline,
innerRef,

Expand Down Expand Up @@ -180,6 +187,11 @@ export default function Section(localProps: SectionAllProps) {
...computeStyle(backgroundColor, 'background-color', (value) =>
getColor(value)
),
...computeStyle(
dropShadow,
'drop-shadow',
(value) => value && 'var(--shadow-default)'
),
...computeStyle(outline, 'outline-color', (value) =>
String(value) === 'true'
? 'var(--outline-color--value)'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ exports[`Section scss has to match style dependencies css 1`] = `
.dnb-section[style*="--background-color"] {
background-color: var(--background-color, white);
}
.dnb-section::before {
content: "";
position: absolute;
inset: 0;
box-shadow: var(--drop-shadow, none);
}
.dnb-section::after {
content: "";
visibility: var(--breakout, hidden);
Expand All @@ -57,6 +63,7 @@ exports[`Section scss has to match style dependencies css 1`] = `
--background-color--value: var(--background-color--small);
--text-color--value: var(--text-color--small);
--outline-color: var(--outline-color--small);
--drop-shadow: var(--drop-shadow--small);
--rounded-corner: var(
--rounded-corner--small,
var(--rounded-corner--fallback)
Expand All @@ -69,6 +76,7 @@ exports[`Section scss has to match style dependencies css 1`] = `
--background-color--value: var(--background-color--medium);
--text-color--value: var(--text-color--medium);
--outline-color: var(--outline-color--medium);
--drop-shadow: var(--drop-shadow--medium);
--rounded-corner: var(
--rounded-corner--medium,
var(--rounded-corner--fallback)
Expand All @@ -81,6 +89,7 @@ exports[`Section scss has to match style dependencies css 1`] = `
--background-color--value: var(--background-color--large);
--text-color--value: var(--text-color--large);
--outline-color: var(--outline-color--large);
--drop-shadow: var(--drop-shadow--large);
--rounded-corner: var(
--rounded-corner--large,
var(--rounded-corner--fallback)
Expand Down
10 changes: 10 additions & 0 deletions packages/dnb-eufemia/src/components/section/style/dnb-section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
background-color: var(--background-color, white);
}

&::before {
content: '';
position: absolute;
inset: 0;
box-shadow: var(--drop-shadow, none);
}

&::after {
content: '';
visibility: var(--breakout, hidden);
Expand Down Expand Up @@ -58,6 +65,7 @@
--background-color--value: var(--background-color--small);
--text-color--value: var(--text-color--small);
--outline-color: var(--outline-color--small);
--drop-shadow: var(--drop-shadow--small);
--rounded-corner: var(
--rounded-corner--small,
var(--rounded-corner--fallback)
Expand All @@ -68,6 +76,7 @@
--background-color--value: var(--background-color--medium);
--text-color--value: var(--text-color--medium);
--outline-color: var(--outline-color--medium);
--drop-shadow: var(--drop-shadow--medium);
--rounded-corner: var(
--rounded-corner--medium,
var(--rounded-corner--fallback)
Expand All @@ -78,6 +87,7 @@
--background-color--value: var(--background-color--large);
--text-color--value: var(--text-color--large);
--outline-color: var(--outline-color--large);
--drop-shadow: var(--drop-shadow--large);
--rounded-corner: var(
--rounded-corner--large,
var(--rounded-corner--fallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,12 @@ button.dnb-button::-moz-focus-inner {
.dnb-section[style*="--background-color"] {
background-color: var(--background-color, white);
}
.dnb-section::before {
content: "";
position: absolute;
inset: 0;
box-shadow: var(--drop-shadow, none);
}
.dnb-section::after {
content: "";
visibility: var(--breakout, hidden);
Expand All @@ -618,6 +624,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--small);
--text-color--value: var(--text-color--small);
--outline-color: var(--outline-color--small);
--drop-shadow: var(--drop-shadow--small);
--rounded-corner: var(
--rounded-corner--small,
var(--rounded-corner--fallback)
Expand All @@ -630,6 +637,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--medium);
--text-color--value: var(--text-color--medium);
--outline-color: var(--outline-color--medium);
--drop-shadow: var(--drop-shadow--medium);
--rounded-corner: var(
--rounded-corner--medium,
var(--rounded-corner--fallback)
Expand All @@ -642,6 +650,7 @@ button.dnb-button::-moz-focus-inner {
--background-color--value: var(--background-color--large);
--text-color--value: var(--text-color--large);
--outline-color: var(--outline-color--large);
--drop-shadow: var(--drop-shadow--large);
--rounded-corner: var(
--rounded-corner--large,
var(--rounded-corner--fallback)
Expand Down
Loading