Skip to content

Commit

Permalink
Initial implementation of optimization for high contrast header removal
Browse files Browse the repository at this point in the history
  • Loading branch information
at-susie authored and michaeldowseza committed Jan 18, 2024
1 parent d1f6584 commit 0e17f95
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pages/app-layout/with-cards.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function () {
ariaLabels={labels}
breadcrumbs={<Breadcrumbs />}
navigation={<Navigation />}
contentType="table"
contentType="cards"
tools={<Tools>{toolsContent[selectedTool]}</Tools>}
toolsOpen={toolsOpen}
onToolsChange={({ detail }) => setToolsOpen(detail.open)}
Expand Down
6 changes: 5 additions & 1 deletion src/app-layout/visual-refresh/mobile-toolbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ section.mobile-toolbar {
align-items: center;
background-color: awsui.$color-background-layout-main;
border-bottom: 1px solid awsui.$color-border-divider-default;
box-shadow: awsui.$shadow-panel-toggle;
box-shadow: awsui.$shadow-flash-sticky;
box-sizing: border-box;
height: var(#{custom-props.$mobileBarHeight});
display: grid;
Expand All @@ -22,6 +22,10 @@ section.mobile-toolbar {
position: sticky;
top: var(#{custom-props.$offsetTop});
z-index: 1000;
&:not(.remove-high-contrast-header) {
background-color: awsui.$color-background-home-header;
box-shadow: awsui.$shadow-panel-toggle;
}

> .mobile-toolbar-nav {
grid-column: 1;
Expand Down
4 changes: 3 additions & 1 deletion src/app-layout/visual-refresh/mobile-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MobileTriggers as DrawersMobileTriggers } from './drawers';
import { useAppLayoutInternals } from './context';
import styles from './styles.css.js';
import testutilStyles from '../test-classes/styles.css.js';
import { isHighContrastHeaderActive } from '../../internal/utils/content-header-utils';

export default function MobileToolbar() {
const {
Expand Down Expand Up @@ -45,7 +46,8 @@ export default function MobileToolbar() {
[styles.unfocusable]: hasDrawerViewportOverlay,
},
testutilStyles['mobile-bar'],
contentHeaderClassName
contentHeaderClassName,
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
>
{!navigationHide && (
Expand Down
5 changes: 4 additions & 1 deletion src/app-layout/visual-refresh/trigger-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ handleSplitPanelMaxWidth function in the context.

.trigger-wrapper {
position: relative;
box-shadow: awsui.$shadow-panel-toggle;
border-radius: 50%;

&:not(.remove-high-contrast-header) {
box-shadow: awsui.$shadow-panel-toggle;
}
}

.dot {
Expand Down
5 changes: 4 additions & 1 deletion src/app-layout/visual-refresh/trigger-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Icon from '../../icon/internal';
import styles from './styles.css.js';
import { ButtonProps } from '../../button/interfaces';
import { IconProps } from '../../icon/interfaces';
import { isHighContrastHeaderActive } from '../../internal/utils/content-header-utils';

export interface TriggerButtonProps {
ariaLabel?: string;
Expand Down Expand Up @@ -36,7 +37,9 @@ function TriggerButton(
ref: React.Ref<ButtonProps.Ref>
) {
return (
<div className={clsx(styles['trigger-wrapper'])}>
<div
className={clsx(styles['trigger-wrapper'], isHighContrastHeaderActive && styles['remove-high-contrast-header'])}
>
<button
aria-expanded={ariaExpanded}
aria-controls={ariaControls}
Expand Down
12 changes: 10 additions & 2 deletions src/cards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { useContainerQuery } from '@cloudscape-design/component-toolkit';
import { AnalyticsFunnelSubStep } from '../internal/analytics/components/analytics-funnel';
import { CollectionLabelContext } from '../internal/context/collection-label-context';
import { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';
import { isHighContrastHeaderActive } from '../internal/utils/content-header-utils';

export { CardsProps };

Expand Down Expand Up @@ -147,7 +148,8 @@ const Cards = React.forwardRef(function <T = any>(
className={clsx(
styles.header,
isRefresh && styles['header-refresh'],
styles[`header-variant-${computedVariant}`]
styles[`header-variant-${computedVariant}`],
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
>
<CollectionLabelContext.Provider value={{ assignId: setHeaderRef }}>
Expand All @@ -166,7 +168,13 @@ const Cards = React.forwardRef(function <T = any>(
__darkHeader={computedVariant === 'full-page'}
__disableFooterDivider={true}
>
<div className={clsx(hasToolsHeader && styles['has-header'])}>
<div
className={clsx(
hasToolsHeader && styles['has-header'],
isRefresh && styles.refresh,
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
>
{!!renderAriaLive && !!firstIndex && (
<LiveRegion>
<span>
Expand Down
5 changes: 5 additions & 0 deletions src/cards/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
// Unfortunately, we don't have access to the header of InternalContainer
// in order to use margin-bottom instead.
margin-top: awsui.$space-grid-gutter;
&.refresh {
&.remove-high-contrast-header {
margin-top: awsui.$space-scaled-s;
}
}
}

.card {
Expand Down
39 changes: 26 additions & 13 deletions src/container/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import styles from './styles.css.js';
import { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
import { useModalContext } from '../internal/context/modal-context';
import { useUniqueId } from '../internal/hooks/use-unique-id';
import { isHighContrastHeaderActive } from '../internal/utils/content-header-utils';

export interface InternalContainerProps extends Omit<ContainerProps, 'variant'>, InternalBaseComponentProps {
__stickyHeader?: boolean;
Expand Down Expand Up @@ -103,6 +104,7 @@ export default function InternalContainer({
* stays in the same vertical position as the header content.
*/
useEffect(() => {
console.log('hello' + isHighContrastHeaderActive);
const shouldUpdateStickyBackground = isSticky && variant === 'full-page' && setHasStickyBackground;
if (shouldUpdateStickyBackground) {
setHasStickyBackground(true);
Expand All @@ -121,7 +123,7 @@ export default function InternalContainer({

const hasMedia = !!media?.content;
const mediaPosition = media?.position ?? 'top';

console.log(isHighContrastHeaderActive);
return (
<div
{...baseProps}
Expand Down Expand Up @@ -153,15 +155,21 @@ export default function InternalContainer({
{header && (
<StickyHeaderContext.Provider value={{ isStuck }}>
<div
className={clsx(isRefresh && styles.refresh, styles.header, styles[`header-variant-${variant}`], {
[styles['header-sticky-disabled']]: __stickyHeader && !isSticky,
[styles['header-sticky-enabled']]: isSticky,
[styles['header-dynamic-height']]: hasDynamicHeight,
[styles['header-stuck']]: isStuck,
[styles['with-paddings']]: !disableHeaderPaddings,
[styles['with-hidden-content']]: !children || __hiddenContent,
[styles['header-with-media']]: hasMedia,
})}
className={clsx(
isRefresh && styles.refresh,
styles.header,
styles[`header-variant-${variant}`],
isHighContrastHeaderActive && styles['remove-high-contrast-header'],
{
[styles['header-sticky-disabled']]: __stickyHeader && !isSticky,
[styles['header-sticky-enabled']]: isSticky,
[styles['header-dynamic-height']]: hasDynamicHeight,
[styles['header-stuck']]: isStuck,
[styles['with-paddings']]: !disableHeaderPaddings,
[styles['with-hidden-content']]: !children || __hiddenContent,
[styles['header-with-media']]: hasMedia,
}
)}
{...stickyStyles}
ref={headerMergedRef}
>
Expand All @@ -174,9 +182,14 @@ export default function InternalContainer({
</StickyHeaderContext.Provider>
)}
<div
className={clsx(styles.content, fitHeight && styles['content-fit-height'], {
[styles['with-paddings']]: !disableContentPaddings,
})}
className={clsx(
styles.content,
fitHeight && styles['content-fit-height'],
isHighContrastHeaderActive && styles['remove-high-contrast-header'],
{
[styles['with-paddings']]: !disableContentPaddings,
}
)}
>
{children}
</div>
Expand Down
18 changes: 18 additions & 0 deletions src/container/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@
&-variant-full-page.header-stuck {
box-shadow: none;

&::before {
content: '';

position: absolute;
right: 0;
left: 0;
bottom: 0;
top: 0;
border-bottom: solid awsui.$border-divider-section-width awsui.$color-border-divider-default;
}

&::after {
content: '';

Expand All @@ -202,6 +213,13 @@
// This polygon only shows the part of the shadow that is lower than the element itself.
clip-path: polygon(-999% 100%, 999% 100%, 999% 999%, -999% 999%);
}

&:not(.remove-high-contrast-header) {
&::before {
content: '';
border-bottom: none;
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/internal/utils/content-header-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import { getGlobalFlag } from './global-flags';
export const contentHeaderClassName: string = getGlobalFlag('removeHighContrastHeader')
? ''
: 'awsui-context-content-header';

export const isHighContrastHeaderActive = !!getGlobalFlag('removeHighContrastHeader');
15 changes: 13 additions & 2 deletions src/wizard/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { WizardProps } from './interfaces';

import styles from './styles.css.js';
import { useFunnelChangeEvent } from './analytics';
import { isHighContrastHeaderActive } from '../internal/utils/content-header-utils';

type InternalWizardProps = WizardProps & InternalBaseComponentProps;

Expand Down Expand Up @@ -148,7 +149,12 @@ export default function InternalWizard({
return (
<div {...baseProps} {...funnelProps} ref={ref} className={clsx(styles.root, baseProps.className)}>
<div
className={clsx(styles.wizard, isVisualRefresh && styles.refresh, smallContainer && styles['small-container'])}
className={clsx(
styles.wizard,
isVisualRefresh && styles.refresh,
smallContainer && styles['small-container'],
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
>
<WizardNavigation
activeStepIndex={actualActiveStepIndex}
Expand All @@ -163,7 +169,12 @@ export default function InternalWizard({
steps={steps}
/>
<div
className={clsx(styles.form, isVisualRefresh && styles.refresh, smallContainer && styles['small-container'])}
className={clsx(
styles.form,
isVisualRefresh && styles.refresh,
smallContainer && styles['small-container'],
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
>
{isVisualRefresh && <div className={clsx(styles.background, contentHeaderClassName)} />}
<WizardForm
Expand Down
30 changes: 22 additions & 8 deletions src/wizard/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
display: grid;
grid-template-columns: auto minmax(0, 1fr);
grid-template-rows: auto 1fr;
row-gap: awsui.$space-scaled-xl;
row-gap: awsui.$space-scaled-xxs;

&.small-container {
grid-template-columns: minmax(0, 1fr) 0;
row-gap: awsui.$space-scaled-l;
}
&:not(.remove-high-contrast-header) {
row-gap: awsui.$space-scaled-xl;
}
}

.wizard:not(.refresh) {
Expand All @@ -35,14 +38,18 @@
grid-row: 1 / span 2;
padding-top: var(#{custom-props.$containerFirstGap}, 0px);

> ul {
> ul.refresh {
background: awsui.$color-background-container-content;
position: relative;
@include styles.container-style;
margin: 0;
padding: awsui.$space-scaled-m awsui.$space-l awsui.$space-scaled-l awsui.$space-m;
width: 280px;
padding: awsui.$space-scaled-xxs 0 0 0;
width: 260px;
box-sizing: border-box;
&:not(.remove-high-contrast-header) {
@include styles.container-style;
padding: awsui.$space-scaled-m awsui.$space-l awsui.$space-scaled-l awsui.$space-m;
width: 280px;
}

> li {
display: grid;
Expand Down Expand Up @@ -172,7 +179,7 @@
padding-top: awsui.$space-xxs;
width: 20 * styles.$base-size;

> ul {
> ul:not(.refresh) {
list-style: none;
padding: 0;
margin: 0;
Expand Down Expand Up @@ -222,8 +229,15 @@
}

> .form-header > .form-header-content {
padding-top: calc(var(#{custom-props.$containerFirstGap}, 0px) + awsui.$space-s);
padding-bottom: awsui.$space-scaled-m;
padding-top: calc(var(#{custom-props.$containerFirstGap}, 0px) + awsui.$space-m - awsui.$space-xxxs);
padding-bottom: awsui.$space-scaled-s;
}

&:not(.remove-high-contrast-header) {
> .form-header > .form-header-content {
padding-top: calc(var(#{custom-props.$containerFirstGap}, 0px) + awsui.$space-s);
padding-bottom: awsui.$space-scaled-m;
}
}

> .form-component {
Expand Down
10 changes: 9 additions & 1 deletion src/wizard/wizard-form-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';
import { useDynamicOverlap } from '../internal/hooks/use-dynamic-overlap';
import { contentHeaderClassName } from '../internal/utils/content-header-utils';
import styles from './styles.css.js';
import { isHighContrastHeaderActive } from '../internal/utils/content-header-utils';

interface WizardFormHeaderProps {
children: React.ReactNode;
Expand All @@ -24,7 +25,14 @@ export default function WizardFormHeader({ children, isVisualRefresh }: WizardFo
)}
ref={overlapElement}
>
<div className={clsx(styles['form-header-content'])}>{children}</div>
<div
className={clsx(
styles['form-header-content'],
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
>
{children}
</div>
</div>
);
}
16 changes: 14 additions & 2 deletions src/wizard/wizard-navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import InternalLink from '../link/internal';
import InternalBox from '../box/internal';
import { WizardProps } from './interfaces';
import styles from './styles.css.js';
import { isHighContrastHeaderActive } from '../internal/utils/content-header-utils';

interface NavigationProps {
activeStepIndex: number;
Expand Down Expand Up @@ -50,10 +51,21 @@ export default function Navigation({
}: NavigationProps) {
return (
<nav
className={clsx(styles.navigation, hidden && styles.hidden, isVisualRefresh && styles.refresh)}
className={clsx(
styles.navigation,
hidden && styles.hidden,
isVisualRefresh && styles.refresh,
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
aria-label={i18nStrings.navigationAriaLabel}
>
<ul className={clsx(isVisualRefresh && styles.refresh)}>
<ul
className={clsx(
styles.list,
isVisualRefresh && styles.refresh,
isHighContrastHeaderActive && styles['remove-high-contrast-header']
)}
>
{steps.map((step, index: number) =>
isVisualRefresh ? (
<NavigationStepVisualRefresh
Expand Down

0 comments on commit 0e17f95

Please sign in to comment.