Skip to content

Commit

Permalink
UBERF-7090: Add QMS common components (#5711)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Zinoviev <[email protected]>
  • Loading branch information
lexiv0re authored Jun 3, 2024
1 parent 6fcabb9 commit f11a7f4
Show file tree
Hide file tree
Showing 20 changed files with 888 additions and 22 deletions.
42 changes: 42 additions & 0 deletions packages/theme/styles/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,27 @@
--theme-clockface-min-arrow: conic-gradient(at 50% -10px, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 49%, #2F2F3A 50%, rgba(0, 0, 0, 0) 51%, rgba(0, 0, 0, 0) 100%);
--theme-clockface-arrows-holder: radial-gradient(at top center, #2F2F3A, #555555);
--theme-clockface-arrows-shadow: 0 0 1px white;

--theme-dialog-border-color: rgba(255, 255, 255, 0.1);
--theme-dialog-background-color: #2a2938;
--theme-dialog-back-color: #848484;
--theme-icon-stroke: #e8e9e9;
--theme-state-ghost-color: rgba(123, 123, 123, 0.6);
--theme-state-ghost-background-color: rgba(123, 123, 123, 0.1);
--theme-state-ghost-border-color: transparent;
--theme-state-negative-color: #dc5147;
--theme-state-negative-background-color: rgba(220, 81, 71, 0.1);
--theme-state-negative-border-color: rgba(220, 81, 71, 0.15);
--theme-state-positive-color: #139d4a;
--theme-state-positive-background-color: rgba(19, 157, 74, 0.1);
--theme-state-positive-border-color: rgba(19, 157, 74, 0.15);
--theme-state-primary-color: #3070dc;
--theme-state-primary-background-color: rgba(48, 112, 220, 0.1);
--theme-state-primary-border-color: rgba(48, 112, 220, 0.15);
--theme-state-regular-color: #7b7b7b;
--theme-state-regular-background-color: rgba(123, 123, 123, 0.1);
--theme-state-regular-border-color: rgba(123, 123, 123, 0.15);
--theme-wizard-not-visited-color: #34343c;
}

/* Light Theme */
Expand Down Expand Up @@ -536,4 +557,25 @@
--theme-clockface-min-arrow: conic-gradient(at 50% -10px, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 49%, white 50%, rgba(255, 255, 255, 0) 51%, rgba(255, 255, 255, 0) 100%);
--theme-clockface-arrows-holder: radial-gradient(at top center, #eee, #aaa);
--theme-clockface-arrows-shadow: 0 0 1px black;

--theme-icon-stroke: #1f212b;
--theme-dialog-border-color: rgba(0, 0, 0, 0.1);
--theme-dialog-background-color: #ffffff;
--theme-dialog-back-color: #616161;
--theme-state-ghost-color: rgba(123, 123, 123, 0.6);
--theme-state-ghost-background-color: rgba(123, 123, 123, 0.1);
--theme-state-ghost-border-color: transparent;
--theme-state-negative-color: #dc5147;
--theme-state-negative-background-color: rgba(220, 81, 71, 0.1);
--theme-state-negative-border-color: rgba(220, 81, 71, 0.15);
--theme-state-positive-color: #139d4a;
--theme-state-positive-background-color: rgba(19, 157, 74, 0.1);
--theme-state-positive-border-color: rgba(19, 157, 74, 0.15);
--theme-state-primary-color: #3070dc;
--theme-state-primary-background-color: rgba(48, 112, 220, 0.1);
--theme-state-primary-border-color: rgba(48, 112, 220, 0.15);
--theme-state-regular-color: #7b7b7b;
--theme-state-regular-background-color: rgba(123, 123, 123, 0.1);
--theme-state-regular-border-color: rgba(123, 123, 123, 0.15);
--theme-wizard-not-visited-color: #e8e9e9;
}
5 changes: 4 additions & 1 deletion packages/ui/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"NoTimeZonesFound": "No time zones found",
"Selected": "Selected:",
"Spanish": "Spanish",
"Portuguese": "Portuguese"
"Portuguese": "Portuguese",
"Submit": "Submit",
"NextStep": "Next step",
"TypeHere": "Type here..."
}
}
5 changes: 4 additions & 1 deletion packages/ui/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"ThemeDark": "Oscuro",
"ThemeSystem": "Sistema",
"NoTimeZonesFound": "No se encontraron zonas horarias",
"Selected": "Seleccionado:"
"Selected": "Seleccionado:",
"Submit": "Enviar",
"NextStep": "Siguiente paso",
"TypeHere": "Escribe aquí..."
}
}
5 changes: 4 additions & 1 deletion packages/ui/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"ThemeDark": "Escuro",
"ThemeSystem": "Sistema",
"NoTimeZonesFound": "Nenhum fuso horário encontrado",
"Selected": "Selecionado:"
"Selected": "Selecionado:",
"Submit": "Enviar",
"NextStep": "Seguinte passo",
"TypeHere": "Escreva aqui..."
}
}
5 changes: 4 additions & 1 deletion packages/ui/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"ThemeDark": "Тёмная",
"ThemeSystem": "Системная",
"NoTimeZonesFound": "Временные зоны не найдены",
"Selected": "Выбрано:"
"Selected": "Выбрано:",
"Submit": "Отправить",
"NextStep": "Следующий шаг",
"TypeHere": "Вводите здесь..."
}
}
257 changes: 257 additions & 0 deletions packages/ui/src/components/ModernDialog.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
<!--
// Copyright © 2023 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
// Note: migrated from QMS. Should be unified with the platform solutions eventually.
import { createEventDispatcher } from 'svelte'
import type { IntlString } from '@hcengineering/platform'
import { AnySvelteComponent, ButtonKind } from '../types'
import Button from './Button.svelte'
import Label from './Label.svelte'
import Scroller from './Scroller.svelte'
import { resizeObserver } from '../resize'
import ui from '../plugin'
import Close from './icons/Close.svelte'
import Left from './icons/Left.svelte'
export let label: IntlString
export let labelProps: any | undefined = undefined
export let submitLabel: IntlString = ui.string.Submit
export let submitKind: ButtonKind = 'primary'
export let cancelLabel: IntlString = ui.string.Cancel
export let canSubmit: boolean = false
export let shouldSubmitOnEnter: boolean = false
export let shouldCloseOnCancel: boolean = true
export let hasBack: boolean = false
export let isForm: boolean = true
export let embedded: boolean = false
export let width: string | undefined = undefined
export let isFooterBorderHidden = false
export let loading = false
export let noContentPadding = false
export let scrollableContent = true
export let withoutFooter = false
export let closeIcon: AnySvelteComponent = Close
export let shadow: boolean = false
const dispatch = createEventDispatcher()
function submit (): void {
dispatch('submit')
}
function close (): void {
dispatch('close')
}
function cancel (): void {
dispatch('cancel')
if (shouldCloseOnCancel) {
close()
}
}
</script>

<svelte:element
this={isForm ? 'form' : 'div'}
class="root"
class:shadow
class:embedded
on:submit|preventDefault={isForm && shouldSubmitOnEnter ? submit : undefined}
use:resizeObserver={() => {
dispatch('changeContent')
}}
style:width
>
<div class="header">
<slot name="headerLeft">
<div class="headerLeft">
<div class="flex-row-center flex-gap-2">
{#if hasBack}
<div class="back">
<Button
icon={Left}
iconProps={{ size: 'small' }}
size="small"
kind="ghost"
label={ui.string.Back}
on:click={() => dispatch('back')}
/>
</div>
{/if}
<slot name="headerExtra" />
</div>
<span class="label"><Label {label} params={labelProps} /></span>
</div>
</slot>
<slot name="headerRight">
{#if !embedded}
<Button icon={closeIcon} iconProps={{ size: 'medium' }} kind="ghost" size="small" on:click={close} />
{/if}
</slot>
</div>

{#if scrollableContent}
<Scroller>
<div class="content" class:noPadding={noContentPadding}>
{#if !noContentPadding}
<div class="htPadding" />
{/if}
<slot />
{#if !noContentPadding}
<div class="hbPadding" />
{/if}
</div>
</Scroller>
{:else}
<div class="content" class:noPadding={noContentPadding}>
{#if !noContentPadding}
<div class="htPadding" />
{/if}
<slot />
{#if !noContentPadding}
<div class="hbPadding" />
{/if}
</div>
{/if}

{#if !withoutFooter || $$slots.footerExtra || $$slots.footerButtons || $$slots.btnsXtraStart || $$slots.btnsXtraBetween || $$slots.btnsXtraEnd}
<div class="footer tweak-buttons" class:footerWithBorder={!isFooterBorderHidden}>
<slot name="footerExtra">
<div />
</slot>

<div class="footerButtons">
<slot name="footerButtons">
<slot name="btnsXtraStart" />
<Button kind="regular" size="large" label={cancelLabel} on:click={cancel} {loading} />
<slot name="btnsXtraBetween" />
<Button
kind={submitKind}
size="large"
label={submitLabel}
focusIndex={10001}
disabled={!canSubmit}
on:click={submit}
{loading}
/>
<slot name="btnsXtraEnd" />
</slot>
</div>
</div>
{/if}
</svelte:element>

<style lang="scss">
.root {
display: flex;
flex-direction: column;
align-items: stretch;
width: 58.25rem;
max-height: 80vh;
border-radius: 1.25rem;
background-color: var(--theme-dialog-background-color);
&.embedded {
width: 100%;
height: 100%;
max-height: unset;
border-radius: 0;
}
}
.shadow {
box-shadow: var(--theme-popup-shadow);
}
.header {
flex: 0 0 auto;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
padding: 1.25rem 2rem 0.875rem 2.5rem;
border-bottom: 1px solid var(--theme-dialog-border-color);
}
.headerLeft {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.back {
:global(button) {
color: var(--theme-dialog-back-color) !important;
padding-left: 0 !important;
}
}
.label {
font-size: 1.25rem;
color: var(--theme-caption-color);
}
// we need these elements as paddings because Scroller doesn't respect css padding
.htPadding {
width: 100%;
height: 1.25rem;
}
.hbPadding {
width: 100%;
height: 2rem;
}
.content {
display: flex;
flex-direction: column;
align-items: stretch;
flex: 1 1 auto;
min-height: 0;
padding: 0 2.5rem 0 2.5rem;
&.noPadding {
padding: 0;
}
}
.footer {
flex: 0 0 auto;
height: 4.875rem;
padding: 1.25rem 2.5rem;
display: flex;
justify-content: space-between;
align-items: center;
&.footerWithBorder {
border-top: 1px solid var(--theme-dialog-border-color);
}
}
.footerButtons {
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 0.75rem;
}
// TODO: remove when supported on the platform
.tweak-buttons {
:global(button) {
min-width: 6.25rem !important;
}
}
</style>
Loading

0 comments on commit f11a7f4

Please sign in to comment.