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

Page: make 'standard' the default maxWidth option #2979

Merged
merged 21 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
73f02cd
Make standard the default maxWidth option for page
thupi Mar 31, 2023
29cd80e
Remove standard as a maxWidth option
mark-drastrup Jul 24, 2023
fbca6bc
Remove tests for the removed width
mark-drastrup Jul 24, 2023
70951ae
Add console warning when using standard width
mark-drastrup Jul 26, 2023
ee7e788
Restore test that should be removed in next major
RasmusKjeldgaard Aug 1, 2023
82fb392
Set default page width top correct value
RasmusKjeldgaard Aug 2, 2023
fa8a38c
Update test with correct default page width
RasmusKjeldgaard Aug 7, 2023
dc80395
Rename page max width variable
RasmusKjeldgaard Aug 22, 2023
59932bd
Merge remote-tracking branch 'origin/develop' into enhancement/page-f…
RasmusKjeldgaard Aug 22, 2023
b0f2d55
Introduce max width map to avoid magic numbers
RasmusKjeldgaard Aug 22, 2023
83984b9
Update tests to use DesignTokenHelper
RasmusKjeldgaard Aug 22, 2023
eff7270
Merge remote-tracking branch 'origin/develop' into enhancement/page-f…
RasmusKjeldgaard Aug 22, 2023
bc30c44
Add migration notes for deprecated page width variable
RasmusKjeldgaard Aug 23, 2023
866df1b
Clarify deprecation message for page content width variable
RasmusKjeldgaard Aug 23, 2023
0a1343d
Fix typos
RasmusKjeldgaard Aug 29, 2023
b3d8db6
Simplify variable usage
RasmusKjeldgaard Aug 29, 2023
a796cd6
Insert linebreak for readability
RasmusKjeldgaard Aug 29, 2023
bce0a62
Clarify text
RasmusKjeldgaard Aug 29, 2023
2ab2c3c
Update libs/designsystem/tab-navigation/src/tab-navigation/tab-naviga…
RasmusKjeldgaard Aug 29, 2023
c992728
Update libs/designsystem/src/lib/components/page-local-navigation/pag…
RasmusKjeldgaard Aug 29, 2023
2d1936e
Update libs/designsystem/page/src/page-footer/page-footer.component.scss
RasmusKjeldgaard Aug 29, 2023
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
6 changes: 6 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ The Experimental Alert has been fully removed and we recommend to use the normal

A new `xsmall` breakpoint (`320px`) has been introduced in the `$breakpoints` map exposed by Kirby. The `xsmall` breakpoint replaces the old `small` breakpoint, which is now `632px`.

A `$page-content-max-widths` map has been introduced to support `default`, `optimized` and `full`-width content on Kirby Page. This means that the standalone variable `$page-content-max-width` is deprecated in v9 and `$page-content-max-width-default` should be used in its place.
For backwards compatability both variables return the `default` value until v10 where `$page-content-max-width` is removed entirely in favor of `$page-content-max-width-default`.
<br>

Values from the new content-width map can be retrieved with the `get-page-content-max-width()` convenience function, e.g. `get-page-content-max-width('full')`.

## Version 8.3.0

- [Components](#components-v8-3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const fieldsetHtml = `
<fieldset>
<legend>Max Width</legend>
<select (change)="onMaxWidthChange($event.target.value)">
<option value="">-</option>
<option
*ngFor="let option of maxWidthOptions"
value="{{ option.value }}"
Expand Down Expand Up @@ -42,10 +41,6 @@ export class PageContentWidthExampleComponent extends BasePageExampleComponent {
text: 'default',
value: 'default',
},
{
text: 'standard',
value: 'standard',
},
{
text: 'optimized',
value: 'optimized',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class PageShowcaseComponent {
name: 'maxWidth',
description: 'Sets the max width for the content',
defaultValue: 'default',
type: ['default', 'standard', 'optimized', 'full'],
type: ['default', 'optimized', 'full'],
},
];
events: ApiDescriptionEvent[] = [
Expand Down
4 changes: 4 additions & 0 deletions libs/core/src/helpers/design-token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export class DesignTokenHelper {
public static zLayer(key: keyof typeof styles.zLayers): string {
return styles.zLayers[key];
}

public static pageContentMaxWidth(key: keyof typeof styles.pageContentMaxWidths): string {
return styles.pageContentMaxWidths[key];
}
}

export type ThemeColorExtended =
Expand Down
4 changes: 4 additions & 0 deletions libs/core/src/scss/base/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
@return $shadow-size;
}

@function get-page-content-max-width($value) {
@return map.get(variables.$page-content-max-widths, $value);
}

@function _get-shadow-value($shadow, $valuekey) {
$shadow-value-map: (
'offset-x': 1,
Expand Down
8 changes: 7 additions & 1 deletion libs/core/src/scss/base/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ $avatar-badge-size: 16px;

/* Page
****************************************************************************/
$page-content-max-width: 720px;
$page-content-max-widths: (
default: 792px,
optimized: 1092px,
full: 100%,
);
$page-content-max-width-default: map.get($page-content-max-widths, 'default');
$page-content-max-width: $page-content-max-width-default;

/* Modal
****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $padding-vertical: utils.size('xxs');

.wrapper {
position: relative;
max-width: var(--page-content-max-width, utils.$page-content-max-width);
max-width: var(--page-content-max-width, utils.$page-content-max-width-default);
margin: 0 auto;
padding-bottom: var(--kirby-page-footer-safe-area-bottom, var(--kirby-safe-area-bottom));

Expand Down
14 changes: 5 additions & 9 deletions libs/designsystem/page/src/page.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ ion-back-button {
* Page Header
*/
.page-header-container {
max-width: var(--page-content-max-width, utils.$page-content-max-width);
max-width: var(--page-content-max-width, utils.$page-content-max-width-default);
margin: 0 auto;
}

Expand Down Expand Up @@ -267,20 +267,16 @@ ion-content {
--padding-top: 0;
}

&.max-width-standard {
--page-content-max-width: 792px;
}

&.max-width-optimized {
--page-content-max-width: 1092px;
--page-content-max-width: #{utils.get-page-content-max-width('optimized')};
}

&.max-width-full {
--page-content-max-width: 100%;
--page-content-max-width: #{utils.get-page-content-max-width('full')};
}

.content-inner {
max-width: var(--page-content-max-width, utils.$page-content-max-width);
max-width: var(--page-content-max-width, utils.$page-content-max-width-default);
margin: 0 auto;
padding-bottom: utils.size('xl');
}
Expand Down Expand Up @@ -316,7 +312,7 @@ ion-content {
z-index: utils.z('sticky-content');

div {
max-width: var(--page-content-max-width, utils.$page-content-max-width);
max-width: var(--page-content-max-width, utils.$page-content-max-width-default);
margin: 0 auto;
}

Expand Down
8 changes: 4 additions & 4 deletions libs/designsystem/page/src/page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ describe('PageComponent', () => {
await TestHelper.whenReady(ionContent);
const contentInner = ionContent.querySelector('.content-inner');
expect(contentInner).toHaveComputedStyle({
'max-width': '720px',
'max-width': DesignTokenHelper.pageContentMaxWidth('default'),
jakobe marked this conversation as resolved.
Show resolved Hide resolved
});
});

Expand All @@ -807,7 +807,7 @@ describe('PageComponent', () => {
await TestHelper.whenReady(ionContent);
const contentInner = ionContent.querySelector('.content-inner');
expect(contentInner).toHaveComputedStyle({
'max-width': '792px',
'max-width': DesignTokenHelper.pageContentMaxWidth('default'),
});
});
});
Expand All @@ -822,7 +822,7 @@ describe('PageComponent', () => {
await TestHelper.whenReady(ionContent);
const contentInner = ionContent.querySelector('.content-inner');
expect(contentInner).toHaveComputedStyle({
'max-width': '1092px',
'max-width': DesignTokenHelper.pageContentMaxWidth('optimized'),
});
});
});
Expand All @@ -837,7 +837,7 @@ describe('PageComponent', () => {
await TestHelper.whenReady(ionContent);
const contentInner = ionContent.querySelector('.content-inner');
expect(contentInner).toHaveComputedStyle({
'max-width': '100%',
'max-width': DesignTokenHelper.pageContentMaxWidth('full'),
});
});
});
Expand Down
19 changes: 18 additions & 1 deletion libs/designsystem/page/src/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const contentScrolledOffsetInPixels = 4;

type stickyConfig = { sticky: boolean };
type fixedConfig = { fixed: boolean };
type MaxWidth = 'default' | 'standard' | 'optimized' | 'full';

const PAGE_WIDTH_STANDARD_DEPRECATION_WARNING =
'Deprecation warning: The support for "standard" as a maxWidth option will be removed in Kirby version 10. After that the "standard" width will be the default width and does not need to be specified.';

export const PAGE_BACK_BUTTON_OVERRIDE = new InjectionToken<PageBackButtonOverride>(
'page-back-button-override'
Expand Down Expand Up @@ -225,9 +229,22 @@ export class PageComponent
@Input() defaultBackHref: string;
@Input() hideBackButton: boolean;
@Input() titleMaxLines: number;
@Input() maxWidth: 'default' | 'standard' | 'optimized' | 'full' = 'default';
@Input() hasInteractiveTitle: boolean;

@Input() set maxWidth(width: MaxWidth) {
if (width === 'standard') {
console.warn(PAGE_WIDTH_STANDARD_DEPRECATION_WARNING);
}

this._maxWidth = width;
}

get maxWidth(): MaxWidth {
return this._maxWidth;
}

private _maxWidth: MaxWidth = 'default';

private _tabBarBottomHidden: boolean;
public get tabBarBottomHidden(): boolean {
return this._tabBarBottomHidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $tab-item-text-max-width: 100px;
$bottom-border-height: 1px;
$border-color-standard: utils.get-color('medium');
$border-color-selected: utils.get-color('dark');
$divider-max-width-breakpoint: utils.$page-content-max-width + (utils.size('s') * 2);
$divider-max-width-breakpoint: utils.$page-content-max-width-default + (utils.size('s') * 2);

.tab-bar {
position: relative;
Expand Down Expand Up @@ -33,7 +33,7 @@ $divider-max-width-breakpoint: utils.$page-content-max-width + (utils.size('s')
.container {
position: relative;
background-color: utils.get-color('background-color');
max-width: var(--page-content-max-width, utils.$page-content-max-width);
max-width: var(--page-content-max-width, utils.$page-content-max-width-default);

// Divider
&::before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$bottom-border-height: 1px;
$border-color-standard: utils.get-color('medium');
$divider-max-width-breakpoint: utils.$page-content-max-width + (utils.size('s') * 2);
$divider-max-width-breakpoint: utils.$page-content-max-width-default + (utils.size('s') * 2);

:host {
display: block;
Expand Down
Loading