Skip to content

Commit

Permalink
Merge pull request #2264 from Teradata/feat/full-screen-dialog
Browse files Browse the repository at this point in the history
feat(components): full screen dialog and focused page web components
  • Loading branch information
bsahitya authored Nov 4, 2024
2 parents c77869b + 5a32bcd commit fcf9715
Show file tree
Hide file tree
Showing 12 changed files with 795 additions and 2 deletions.
10 changes: 10 additions & 0 deletions libs/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,21 @@
"import": "./expansion-panel-item.mjs",
"require": "./expansion-panel-item.js"
},
"./focused-page": {
"types": "./focused-page/focused-page.d.ts",
"import": "./focused-page.mjs",
"require": "./focused-page.js"
},
"./formfield": {
"types": "./formfield/formfield.d.ts",
"import": "./formfield.mjs",
"require": "./formfield.js"
},
"./full-screen-dialog": {
"types": "./full-screen-dialog/full-screen-dialog.d.ts",
"import": "./full-screen-dialog.mjs",
"require": "./full-screen-dialog.js"
},
"./icon": {
"types": "./icon/icon.d.ts",
"import": "./icon.mjs",
Expand Down
15 changes: 13 additions & 2 deletions libs/components/src/dialog/dialog.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

:host {
--mdc-dialog-heading-ink-color: var(--mdc-theme-text-primary-on-background);
--mdc-dialog-content-ink-color: var(--mdc-theme-text-primary-on-background);
--mdc-dialog-scroll-divider-color: var(--mdc-theme-border);
--mdc-dialog-scroll-divider-color: var(--mdc-theme-border);

// Allow consumer to set border radius and height of the dialog
.mdc-dialog .mdc-dialog__surface {
border-radius: var(--cv-dialog-border-radius, var(--mdc-shape-medium, 4));
min-height: var(--mdc-dialog-min-height);
}

// Allow consumer to set padding of the dialog content
.mdc-dialog .mdc-dialog__content {
padding: var(--cv-dialog-vertical-padding, 20px)
var(--cv-dialog-horizontal-padding, 24px);
}
}
113 changes: 113 additions & 0 deletions libs/components/src/focused-page/focused-page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
:host {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
}

.action-items {
padding: 0.5rem 0.75rem;
text-align: right;
}

.content {
box-sizing: border-box;
display: flex;
flex: 1;
max-height: 100vh;
overflow: auto;
transition: visibility 0.3s ease;
}

.fullscreen-container {
border-top: 4px solid var(--cv-theme-tertiary);
box-sizing: border-box;
display: flex;
height: 100%;
width: 100%;

&:not(.help-open) .help-panel {
width: 0;

.resize-handle {
display: none;
}
}
}

.fullscreen-container.hide-border {
border: none;
}

.help {
--mdc-theme-surface: var(--cv-theme-surface-container-low);

box-sizing: border-box;
flex: 1;
max-height: 100vh;
overflow-y: auto;
}

.help-panel {
background: var(--cv-theme-surface-container-low);
box-sizing: border-box;
display: flex;
flex: 0 0 auto;
max-width: 100%;
position: relative;
resize: none;
transition: width 200ms;
width: var(--cv-focused-page-help-width, 320px);
z-index: 5;

.resize-handle {
cursor: ew-resize;
height: 100%;
opacity: 0;
position: absolute;
transition: opacity 0.3s ease;
user-select: none;
width: 8px;
z-index: 9;

&::before {
background-color: var(--mdc-theme-primary);
content: '';
height: 100%;
left: 0;
position: absolute;
top: 0;
transform: translateX(-50%);
width: 2px;
}
}

.resize-handle:hover,
&.resizing .resize-handle {
opacity: 1;
}
}

.main {
box-sizing: border-box;
flex: 1;
height: 100%;
}

@media only screen and (max-width: 479.98px) {
.help-open .help-panel {
width: 100%;
z-index: 100;
}
}

@media only screen and (max-width: 959.98px) {
.help-open .help-panel {
box-shadow: 0 8px 12px 6px rgba(0, 0, 0, 15%),
0 4px 4px 0 rgba(0, 0, 0, 30%);
height: 100%;
position: absolute;
right: 0;
}
}
11 changes: 11 additions & 0 deletions libs/components/src/focused-page/focused-page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @vitest-environment jsdom
*/
import { it, describe, expect } from 'vitest';
import { CovalentFocusedPage } from './focused-page';

describe('Covalent Focused Page', () => {
it('should work', () => {
expect(new CovalentFocusedPage()).toBeDefined();
});
});
167 changes: 167 additions & 0 deletions libs/components/src/focused-page/focused-page.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import './focused-page';
import '../button/button';
import '../toolbar/toolbar';
import '../icon-button/icon-button';
import '../icon-button-toggle/icon-button-toggle';
import '../icon-radio/icon-radio-toggle';
import '../typography/typography';
import '../icon/icon';

export default {
title: 'Components/Focused page',
argTypes: {},
args: {
helpOpen: false,
helpResizable: false,
hideTopBorder: false,
},
parameters: {
layout: 'fullscreen',
},
};

const Template = ({ helpOpen, helpResizable, hideTopBorder }) => {
document.addEventListener(
'DOMContentLoaded',
() => {
const helpToggleButton = document.body.querySelector('.help-toggle');

helpToggleButton.addEventListener('click', () => {
const dialog = document.body.querySelector('#focused-page');
dialog.helpOpen = !dialog.helpOpen;
});
},
{ once: true }
);

return `
<cv-focused-page id="focused-page" scrimClickAction="" ${
helpResizable ? ' helpResizable' : ''
}${helpOpen ? ' helpOpen' : ''}${hideTopBorder ? ' hideTopBorder' : ''}>
<!-- Content to be rendered in the focused page component -->
<!-- Replace with any content as desired -->
<cv-toolbar>
<span slot="title">
Connect data source
</span>
<cv-icon-button-toggle onIcon="help" offIcon="help" class="help-toggle"
slot="actionItems"></cv-icon-button-toggle>
</cv-toolbar>
<div style="display:flex; gap: 3rem; flex-wrap: wrap; padding: 2rem 1rem 1.5rem; max-width: 1200px">
<div>
<div style="display:flex;">
<span>
<cv-icon-button-toggle onIcon="info" offIcon="info" toggledOn></cv-icon-button-toggle>
</span>
<div style="display: inline-block; margin: 0 0 1rem 1rem;">
<cv-typography scale="subtitle1">
Select model
</cv-typography>
<cv-typography scale="caption">
Select the industry data model for your organization
</cv-typography>
</div>
</div>
<div style="display:flex; margin-top: 1rem;">
<span>
<cv-icon-button-toggle onIcon="info" offIcon="info" toggledOn></cv-icon-button-toggle>
</span>
<div style="display: inline-block; margin: 0 0 1rem 1rem;">
<cv-typography scale="subtitle1">
Review details
</cv-typography>
<cv-typography scale="caption">
Preview the selected model and sample schema
</cv-typography>
</div>
</div>
<div style="display:flex; margin-top: 1rem;">
<span>
<cv-icon-button-toggle onIcon="info" offIcon="info" toggledOn></cv-icon-button-toggle>
</span>
<div style="display: inline-block; margin: 0 0 1rem 1rem;">
<cv-typography scale="subtitle1">
Install
</cv-typography>
<cv-typography scale="caption">
Acknowledge creation of database and install
</cv-typography>
</div>
</div>
</div>
<div
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 1rem; flex: 1">
<cv-radio-icon>
<cv-icon slot="icon">work</cv-icon>
<div slot="text">Balanced</div>
<div slot="text">Every week</div>
</cv-radio-icon>
<cv-radio-icon>
<cv-icon slot="icon">work</cv-icon>
<div slot="text">Balanced</div>
<div slot="text">Every week</div>
</cv-radio-icon>
<cv-radio-icon>
<cv-icon slot="icon">work</cv-icon>
<div slot="text">Balanced</div>
<div slot="text">Every week</div>
</cv-radio-icon>
<cv-radio-icon>
<cv-icon slot="icon">work</cv-icon>
<div slot="text">Balanced</div>
<div slot="text">Every week</div>
</cv-radio-icon>
</div>
</div>
<!-- Content rendered in the help section of the component -->
<!-- Replace with any content as desired -->
<div slot="help">
<cv-toolbar sticky>
<span slot="title" style="padding-left: 4px;">Help</span>
<cv-icon-button slot="actionItems" icon="undock" covalent-icons></cv-icon-button>
</cv-toolbar>
<div style="padding: 16px">
<cv-typography scale="headline5">
Ultricies nunc massa, id ut felis sed varius accumsan platea.
</cv-typography>
<br />
<cv-typography scale="body1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
tincidunt lectus risus, id aliquet mi congue sed.
</cv-typography>
<br />
<cv-typography scale="body1">
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
pouere cubilia curae; Phasellus tincidunt eros arcu, sollicitudin
laoreet urna aliquet eget.
</cv-typography>
<br />
<cv-typography scale="body1">
Phasellus porta sed libero vel vulputate. Quisque non nisl sem.
Pellentesque nec pretium magna, et vestibulum neque. Mauris molestie
eros quis nisi pretium,
</cv-typography>
<br />
<cv-typography scale="body1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
tincidunt lectus risus, id aliquet mi congue sed.
</cv-typography>
<br />
<cv-typography scale="body1">
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
pouere cubilia curae; Phasellus tincidunt eros arcu, sollicitudin
laoreet urna aliquet eget.
</cv-typography>
<br />
<cv-typography scale="body1">
Phasellus porta sed libero vel vulputate. Quisque non nisl sem.
Pellentesque nec pretium magna, et vestibulum neque. Mauris molestie
eros quis nisi pretium,
</cv-typography>
</div>
</div>
</cv-focused-page>`;
};

export const Basic = Template.bind({});
Loading

0 comments on commit fcf9715

Please sign in to comment.