Fix number and string editors. Update attributes header. (#1823)

Signed-off-by: Alexander Platov <sas_lord@mail.ru>
This commit is contained in:
Alexander Platov
2022-05-22 10:30:59 +06:00
committed by GitHub
parent fcb81f2916
commit f6cb336d4d
10 changed files with 150 additions and 42 deletions
+15 -13
View File
@@ -89,20 +89,22 @@
</svelte:fragment>
<svelte:fragment slot="aside">
<div style="padding: .75rem 1.5rem">
{#if $$slots.actions}
<div class="flex-row-center pb-3 bottom-divider">
<span class="fs-bold w-24 mr-6"><slot name="actions-label" /></span>
<div class="buttons-group xsmall-gap">
<slot name="actions" />
<Scroller>
<div style="padding: .75rem 1.5rem">
{#if $$slots.actions}
<div class="flex-row-center pb-3 bottom-divider">
<span class="fs-bold w-24 mr-6"><slot name="actions-label" /></span>
<div class="buttons-group xsmall-gap">
<slot name="actions" />
</div>
</div>
</div>
{/if}
{#if $$slots['custom-attributes'] && isCustomAttr}
<slot name="custom-attributes" direction="column" />
{:else if $$slots.attributes}<slot name="attributes" direction="column" />{/if}
{#if $$slots.aside}<slot name="aside" />{/if}
</div>
{/if}
{#if $$slots['custom-attributes'] && isCustomAttr}
<slot name="custom-attributes" direction="column" />
{:else if $$slots.attributes}<slot name="attributes" direction="column" />{/if}
{#if $$slots.aside}<slot name="aside" />{/if}
</div>
</Scroller>
</svelte:fragment>
{#if withoutActivity}
@@ -72,7 +72,8 @@
grid-auto-flow: row;
justify-content: start;
align-items: center;
gap: 1rem;
gap: 0.5rem;
padding-bottom: 0.5rem;
width: 100%;
height: min-content;
+2
View File
@@ -65,6 +65,8 @@
scrollbar-width: thin;
--font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto;
--timing-shadow: cubic-bezier(0,.65,.35,1);
--timing-main: cubic-bezier(0.25, 0.46, 0.45, 0.94);
// transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
::-webkit-scrollbar {
+7 -2
View File
@@ -18,7 +18,7 @@
import { afterUpdate, createEventDispatcher, onMount } from 'svelte'
import { registerFocus } from '../focus'
import plugin from '../plugin'
import type { AnySvelteComponent } from '../types'
import type { AnySvelteComponent, EditStyle } from '../types'
import Icon from './Icon.svelte'
import Label from './Label.svelte'
@@ -29,7 +29,7 @@
export let placeholder: IntlString = plugin.string.EditBoxPlaceholder
export let placeholderParam: any | undefined = undefined
export let format: 'text' | 'password' | 'number' = 'text'
export let kind: 'editbox' | 'large-style' | 'small-style' | 'search-style' = 'editbox'
export let kind: EditStyle = 'editbox'
export let focus: boolean = false
const dispatch = createEventDispatcher()
@@ -116,6 +116,7 @@
<input
bind:this={input}
type="number"
class="number"
bind:value
placeholder={phTraslate}
{style}
@@ -185,6 +186,10 @@
width: 0;
margin: 0;
}
&.number::-webkit-outer-spin-button,
&.number::-webkit-inner-spin-button {
-webkit-appearance: none;
}
}
}
</style>
+1
View File
@@ -66,6 +66,7 @@ export type TabModel = Tab[]
export type ButtonKind = 'primary' | 'secondary' | 'no-border' | 'transparent' | 'link' | 'link-bordered' | 'dangerous'
export type ButtonSize = 'small' | 'medium' | 'large' | 'x-large'
export type ButtonShape = 'rectangle' | 'rectangle-left' | 'rectangle-right' | 'circle' | 'round' | undefined
export type EditStyle = 'editbox' | 'large-style' | 'small-style' | 'search-style'
export interface PopupPositionElement {
getBoundingClientRect: () => DOMRect
position?: {
@@ -15,7 +15,7 @@
<script lang="ts">
import { Class, Doc, Ref } from '@anticrm/core'
import presentation, { AttributesBar, getClient, KeyedAttribute } from '@anticrm/presentation'
import { ActionIcon, IconAdd, Label, showPopup } from '@anticrm/ui'
import { Button, IconAdd, Label, showPopup, Tooltip } from '@anticrm/ui'
import view from '@anticrm/view'
import { createEventDispatcher } from 'svelte'
import { collectionsFilter, getFiltredKeys } from '../utils'
@@ -29,6 +29,7 @@
const hierarchy = client.getHierarchy()
let keys: KeyedAttribute[] = []
let collapsed: boolean = false
function updateKeys (ignoreKeys: string[]): void {
const filtredKeys = getFiltredKeys(hierarchy, objectClass._id, ignoreKeys, to)
@@ -41,21 +42,112 @@
</script>
{#if vertical}
<div class="flex-between text-sm mb-4">
<Label label={objectClass.label} />
<ActionIcon
label={presentation.string.Create}
icon={IconAdd}
size="small"
action={() => {
showPopup(view.component.CreateAttribute, { _class: objectClass._id }, 'top', () => {
updateKeys(ignoreKeys)
dispatch('update')
})
}}
/>
<div
class="attrbar-header"
class:collapsed
on:click={() => {
collapsed = !collapsed
}}
>
<div class="flex-row-center">
<span class="overflow-label">
<Label label={objectClass.label} />
</span>
<div class="icon-arrow">
<svg fill="var(--dark-color)" viewBox="0 0 6 6" xmlns="http://www.w3.org/2000/svg">
<path d="M0,0L6,3L0,6Z" />
</svg>
</div>
</div>
<div class="tool">
<Tooltip label={presentation.string.Create}>
<Button
icon={IconAdd}
kind={'transparent'}
on:click={(ev) => {
ev.stopPropagation()
showPopup(view.component.CreateAttribute, { _class: objectClass._id }, 'top', () => {
updateKeys(ignoreKeys)
dispatch('update')
})
}}
/>
</Tooltip>
</div>
</div>
{/if}
{#if keys.length || !vertical}
<AttributesBar {object} {keys} {vertical} />
<div class="collapsed-container" class:collapsed>
<AttributesBar {object} {keys} {vertical} />
</div>
{/if}
<style lang="scss">
.attrbar-header {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0.25rem -0.5rem 0.75rem;
padding: 0 0 0 0.5rem;
font-weight: 600;
color: var(--dark-color);
border: 1px solid var(--divider-color);
border-radius: 0.25rem;
cursor: pointer;
transition-property: color, background-color, border-color;
transition-duration: 0.15s;
transition-timing-function: var(--timing-main);
.icon-arrow {
margin-left: 0.5rem;
width: 0.325rem;
height: 0.325rem;
opacity: 0;
transform-origin: 35% center;
transform: rotate(90deg);
transition-property: transform, opacity;
transition-duration: 0.15s;
transition-timing-function: var(--timing-main);
}
.tool {
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.15s var(--timing-main);
}
&.collapsed {
background-color: var(--divider-color);
border-color: transparent;
.icon-arrow {
opacity: 1;
transform: rotate(0deg);
}
}
&:hover {
color: var(--caption-color);
background-color: var(--menu-bg-select);
border-color: transparent;
.icon-arrow {
opacity: 1;
}
.tool {
opacity: 1;
}
}
}
.collapsed-container {
overflow: hidden;
display: flex;
flex-direction: column;
max-height: 1000px;
transition: max-height 0.2s var(--timing-main);
&.collapsed {
max-height: 0;
}
}
</style>
@@ -28,6 +28,6 @@
<ClassAttributeBar {objectClass} {object} {ignoreKeys} to={undefined} vertical on:update />
{#each mixins as mixin}
<div class="bottom-divider mt-4 mb-2" />
<!-- <div class="bottom-divider mt-4 mb-2" /> -->
<ClassAttributeBar objectClass={mixin} {object} {ignoreKeys} to={objectClass._id} vertical on:update />
{/each}
@@ -17,13 +17,17 @@
import type { IntlString } from '@anticrm/platform'
import { createEventDispatcher } from 'svelte'
import { EditBox } from '@anticrm/ui'
import type { EditStyle } from '@anticrm/ui'
export let value: string
export let value: string | number | undefined
export let format: 'text' | 'password' | 'number'
export let placeholder: IntlString
export let kind: EditStyle = 'search-style'
export let maxWidth: string = '10rem'
const dispatch = createEventDispatcher()
function _onchange (ev: Event) {
function _onchange () {
dispatch('update', value)
}
function _onkeypress (ev: KeyboardEvent) {
@@ -36,8 +40,9 @@
<EditBox
bind:value
{placeholder}
kind={'search-style'}
maxWidth={'10rem'}
{format}
{kind}
{maxWidth}
focus
on:change={_onchange}
on:keypress={_onkeypress}
@@ -16,11 +16,11 @@
<script lang="ts">
import type { IntlString } from '@anticrm/platform'
import { EditBox, Label, showPopup, eventToHTMLElement } from '@anticrm/ui'
import StringEditorPopup from './StringEditorPopup.svelte'
import EditBoxPopup from './EditBoxPopup.svelte'
// export let label: IntlString
export let placeholder: IntlString
export let value: any
export let value: number
export let focus: boolean
export let maxWidth: string = '10rem'
export let onChange: (value: number) => void
@@ -39,7 +39,7 @@
on:click={(ev) => {
if (!shown) {
showPopup(
StringEditorPopup,
EditBoxPopup,
{ value, format: 'number' },
eventToHTMLElement(ev),
(res) => {
@@ -16,11 +16,11 @@
<script lang="ts">
import type { IntlString } from '@anticrm/platform'
import { EditBox, Label, showPopup, eventToHTMLElement } from '@anticrm/ui'
import StringEditorPopup from './StringEditorPopup.svelte'
import EditBoxPopup from './EditBoxPopup.svelte'
// export let label: IntlString
export let placeholder: IntlString
export let value: any
export let value: string
export let focus: boolean
export let maxWidth: string = '10rem'
export let onChange: (value: string) => void
@@ -39,7 +39,7 @@
on:click={(ev) => {
if (!shown) {
showPopup(
StringEditorPopup,
EditBoxPopup,
{ value },
eventToHTMLElement(ev),
(res) => {