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(Coachmark): implement popover and floating ui #5574

Merged
merged 12 commits into from
Jul 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,7 @@ p.c4p--about-modal__copyright-text:first-child {
height: 2.5rem;
}
.c4p--side-panel .c4p--side-panel__slug-and-close {
position: fixed;
position: absolute;
z-index: 10; /* must be higher than title container border bottom */
top: 0;
right: 0;
Expand Down Expand Up @@ -5004,6 +5004,18 @@ th.c4p--datagrid__select-all-toggle-on.button {
align-items: center;
}

.c4p--datagrid__inline-edit--outer-cell-checkbox-focus .cds--checkbox-label::before {
outline: 0.125rem solid var(--cds-focus, #0f62fe);
outline-offset: 1px;
}

.c4p--datagrid__inline-edit--outer-cell-checkbox {
display: flex;
height: -webkit-fill-available;
justify-content: center;
padding-inline: 1rem;
}

.c4p--datagrid__static--outer-cell {
display: flex;
height: -webkit-fill-available;
Expand Down Expand Up @@ -5894,6 +5906,101 @@ th.c4p--datagrid__select-all-toggle-on.button {
}
}

/* stylelint-disable carbon/theme-token-use */
.c4p--http-errors-404__prefix-cls-1 {
fill: none;
}

.c4p--http-errors-404__prefix-cls-67 {
fill: #697077;
}

.c4p--http-errors-404__prefix-cls-68 {
fill: #282828;
}

.c4p--http-errors-404__prefix-cls-69 {
fill: #51565c;
}

.c4p--http-errors-404__prefix-cls-70 {
fill: #002b50;
}

.c4p--http-errors-404__prefix-cls-71 {
fill: #413d3d;
}

.c4p--http-errors-404__prefix-cls-72 {
fill: #908b8b;
}

.c4p--http-errors-404__prefix-cls-75 {
fill: #a4a4a5;
}

.c4p--http-errors-404__prefix-cls-76 {
opacity: 0.15;
}

.c4p--http-errors-403__prefix-cls-1 {
fill: none;
}

.c4p--http-errors-403__prefix-cls-80 {
mix-blend-mode: multiply;
opacity: 0.25;
}

.c4p--http-errors-403__prefix-cls-75 {
fill: #595655;
}

.c4p--http-errors-403__prefix-cls-76 {
opacity: 0.15;
}

.c4p--http-errors-403__prefix-cls-77 {
fill: #373d42;
}

.c4p--http-errors-403__prefix-cls-78 {
fill: #002b50;
}

.c4p--http-errors-403__prefix-cls-81 {
fill: #2b2828;
}

.c4p--http-errors-other__prefix-cls-1 {
fill: none;
}

.c4p--http-errors-other__prefix-cls-69 {
fill: #697077;
}

.c4p--http-errors-other__prefix-cls-70 {
fill: #282828;
}

.c4p--http-errors-other__prefix-cls-71 {
fill: #51565c;
}

.c4p--http-errors-other__prefix-cls-72 {
fill: #e0dbda;
}

.c4p--http-errors-other__prefix-cls-73 {
fill: #003d73;
}

.c4p--http-errors-other__prefix-cls-75 {
opacity: 0.15;
}

/* stylelint-enable */
.c4p--import-modal .cds--modal-close {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ $draghandle-btn-class: #{$block-class}__handle;

visibility: hidden;

&--tooltip {
position: initial;
transform: none !important;
}

&--fixed {
position: fixed;
right: $spacing-05;
Expand All @@ -68,45 +73,19 @@ $draghandle-btn-class: #{$block-class}__handle;
visibility: visible;
}

// CARET STYLING
&__caret {
// background-color: this property is set in _coachmark-overlay-theme.scss
position: absolute;
z-index: 5902;
width: 0;
height: 0;
// border-bottom-color: this property is set in _coachmark-overlay-theme.scss
border-right: $caret-center solid transparent;
border-bottom: solid $caret-center $background-inverse;
border-left: $caret-center solid transparent;
}

// OVERLAY AND CARET POSITIONING
// OVERLAY POSITIONING
&--top {
$horizontal-push: calc($distance-offset - $caret-center);
$translate-y: calc(-1 * (100% + $distance-offset + $caret-height));

transform: translate(-50%, $translate-y);

.#{$block-class}__caret {
left: calc(50% - $caret-center);
transform: rotate(180deg);
}

&-left {
transform: translate(calc(-1 * $distance-offset), $translate-y);
.#{$block-class}__caret {
left: $horizontal-push;
transform: rotate(180deg);
}
}

&-right {
transform: translate(calc(-1 * (100% - $distance-offset)), $translate-y);
.#{$block-class}__caret {
right: $horizontal-push;
transform: rotate(180deg);
}
}
}

Expand All @@ -116,26 +95,13 @@ $draghandle-btn-class: #{$block-class}__handle;
$translate-y: calc($distance-offset + $caret-height);

transform: translate(-50%, $translate-y);
.#{$block-class}__caret {
top: $top;
left: calc(50% - $caret-center);
}

&-left {
transform: translate(calc(-1 * $distance-offset), $translate-y);
.#{$block-class}__caret {
top: $top;
left: $horizontal-push;
}
}

&-right {
transform: translate(calc(-1 * (100% - $distance-offset)), $translate-y);

.#{$block-class}__caret {
top: $top;
right: $horizontal-push;
}
}
}

Expand All @@ -145,28 +111,13 @@ $draghandle-btn-class: #{$block-class}__handle;
$vertical-push: calc($distance-offset - ($caret-height * 0.5));

transform: translate($translate-x, -50%);
.#{$block-class}__caret {
top: calc(50% - ($caret-height * 0.5));
right: $right;
transform: rotate(90deg);
}

&-top {
transform: translate($translate-x, calc(-1 * $distance-offset));
.#{$block-class}__caret {
top: $vertical-push;
right: $right;
transform: rotate(90deg);
}
}

&-bottom {
transform: translate($translate-x, calc(-1 * (100% - $distance-offset)));
.#{$block-class}__caret {
right: $right;
bottom: $vertical-push;
transform: rotate(90deg);
}
}
}

Expand All @@ -176,28 +127,13 @@ $draghandle-btn-class: #{$block-class}__handle;
$vertical-push: calc($distance-offset - ($caret-height * 0.5));

transform: translate($translate-x, -50%);
.#{$block-class}__caret {
top: calc(50% - ($caret-height * 0.5));
left: $left;
transform: rotate(-90deg);
}

&-top {
transform: translate($translate-x, calc(-1 * $distance-offset));
.#{$block-class}__caret {
top: $vertical-push;
left: $left;
transform: rotate(-90deg);
}
}

&-bottom {
transform: translate($translate-x, calc(-1 * (100% - $distance-offset)));
.#{$block-class}__caret {
bottom: $vertical-push;
left: $left;
transform: rotate(-90deg);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Standard imports.
@use '../../global/styles/project-settings' as c4p-settings;
@use '../../global/styles/mixins';
@use '@carbon/styles/scss/config';

@use './coachmark-dragbar';
@use './coachmark-header';
Expand All @@ -23,8 +24,16 @@
// TODO: @use(s) of IBM Products component styles used by Coachmark

// The block part of our conventional BEM class names (blockClass__E--M).
//$block-class: #{c4p-settings.$pkg-prefix}--coachmark;
$block-class: #{c4p-settings.$pkg-prefix}--coachmark;

// .#{$block-class} {
// // TODO: Styles.
// }

.#{$block-class} > .#{config.$prefix}--popover-container {
/* stylelint-disable-next-line declaration-no-important */
position: absolute !important;
bottom: 0;
left: 0;
transform: translate(-50%, 50%);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ $block-class: #{c4p-settings.$pkg-prefix}--coachmark-beacon;
}
.#{$block-class}__target {
// the hit area
position: absolute;
top: calc(-1 * $spacing-05);
left: calc(-1 * $spacing-05);
// position: absolute;
// top: calc(-1 * $spacing-05);
// left: calc(-1 * $spacing-05);
display: flex;
width: $spacing-07;
height: $spacing-07;
padding: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import React, { useEffect, useRef } from 'react';
// TODO: import action to handle events if required.
// import { action } from '@storybook/addon-actions';
import { Crossroads } from '@carbon/react/icons';
Expand Down Expand Up @@ -87,8 +87,13 @@ export default {
* TODO: Declare template(s) for one or more scenarios.
*/
const Template = (args) => {
const ref = useRef();

useEffect(() => {
ref?.current?.scrollIntoView({ block: 'center', inline: 'center' });
});
const theme = getSelectedCarbonTheme();
return (
const content = (
<Coachmark {...args} theme={theme}>
<CoachmarkOverlayElements closeButtonLabel="Done">
<CoachmarkOverlayElement
Expand All @@ -98,6 +103,23 @@ const Template = (args) => {
</CoachmarkOverlayElements>
</Coachmark>
);

return args.overlayKind !== 'floating' ? (
<div style={{ width: '4000px', height: '2000px' }}>
<div
style={{
position: 'absolute',
top: '1000px',
left: '2000px',
}}
ref={ref}
>
{content}
</div>
</div>
) : (
content
);
};

/**
Expand Down
Loading
Loading