* working proto for font size * wip * Font styling - Base classes for font-size and font; - WIP! * working data attribute for fontsize * Font styling - Add `js-style-receiver` to markup, refine style targeting JS for better application of styles; - Refinements to font and size CSS; - WIP! * Font styling - Redo CSS to use `data-*` attributes; - New `u-style-receiver` class for use as font-size and font-family CSS selector target; - New `js-style-receiver` class for use as JS target by ObjectView.vue; - New classes added to markup in all Open MCT views; - Changed font-size values from 'is-font-size--*' to just the number; - Some refinement to individual views to account for font-sizing capability; - Removed automatic font-size 13px being set by SubobjectView.vue; - WIP! * working mixed styles * Font styling - Added `u-style-receiver` to TelemetryView.vue; - Added `icon-font-size` to Font Size dropdown button; - TODO: better font-size icon; * working font-family * Font styling - Art for `icon-font-size` glyph updated; - Redefined glyph usage in some Layout toolbar buttons; - Updated font-size and font dropdown menus options text; * Font styling - Refined font-size and font dropdown values; - Fixed toolbar-select-menu.vue to remove 'px' from non-specific option return; * dont allow font styling on layouts that contain other layouts * fix lint warning * add sizing row * fix bug with column width sizing * fix bug with header style * add saved styles inspector view * WIP * add vue component for selector * WIP styles manager to communicate between vue components * WIP saving and persisting styles * no duplicate styles prevention * fix props syntax * WIP can apply conditional styles * static styles do not work yet * display border color in saved styles swatch * allow deleting styles except default style * WIP apply static style works but also to layout... * prevent additional StylesView from being created * delete style message * change save order * move applystyle to selector component * rename for consistency * naming refactor * add style description * update style properties only if they exist and do not erase properties * refactor singleton usage refactor save method * show save and delete only on hover * do not show delete icon if not in edit mode * normalize styles before saving prevent apply style if conditional and static styles are simultaneously selected * remove default style tweak selector display * allow conditional and static styles to have saved style applied limit saved styles to 20 * refactor styles manager remove openmct dependency use provide/inject * resolve merge conflicts * lint fix * reorganize styles * add font style editor to styles view * save and display border correctly in saved styles view * WIP add font styling controls to inspector styles view * add font constants * WIP refactor to provide reactive props fix locked for edit * WIP display consolidated font styles for selection in editor * WIP font styles saved to layout * WIP persisting font styles from inspector works * fix styleable check * move logic up to stylesview because save is two part * apply font style to thumb * there can be only one * show font style for native views * linting fix * push stylesManager work to StylesView * move method to computed * move constant definition outside of function call * Styling for saved styles functionality WIP - Simplified and removed unnecessary markup; - Standardized style applied to saved style element and toolbar control; - Removed saved style expand arrow and description, replaced with item title / tooltip approach; - Standardized width of `c-style-thumb` element; - Moved font size and style controls to the designed location; * Styling for saved styles functionality WIP - Layout and CSS normalization between style editor control and saved style preview element; - Control alignment refined; - Moved font size and style controls to the designed location; * Styling for saved styles functionality WIP - Update font size icon art to normalize size; - Sanding, tweaking, alignin and layout in style controls area of Inspector; * Styling for saved styles functionality WIP - Hide the font size and style menu buttons unless the user is editing; * remove font controls from toolbar * turn styles tab into multipane element * lint fix * no font style should not be viewed as non-specific * delete saved style by index not style * cleanup * view and inspector view updates on initial font change * revert computed back to method * set initial height * fix test after removing 2 buttons from toolbar * fix hidden lint error * fix lint Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov> Co-authored-by: charlesh88 <charlesh88@gmail.com>
246 lines
9.0 KiB
Vue
246 lines
9.0 KiB
Vue
/*****************************************************************************
|
|
* Open MCT, Copyright (c) 2014-2020, United States Government
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
* Administration. All rights reserved.
|
|
*
|
|
* Open MCT is licensed under the Apache 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
|
|
* http://www.apache.org/licenses/LICENSE-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.
|
|
*
|
|
* Open MCT includes source code licensed under additional open source
|
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
|
* this source code distribution or the Licensing information page available
|
|
* at runtime from the About dialog for additional information.
|
|
*****************************************************************************/
|
|
|
|
<template>
|
|
<div class="c-style has-local-controls c-toolbar">
|
|
<div class="c-style__controls">
|
|
<div :class="[
|
|
{ 'is-style-invisible': styleItem.style && styleItem.style.isStyleInvisible },
|
|
{ 'c-style-thumb--mixed': mixedStyles.indexOf('backgroundColor') > -1 }
|
|
]"
|
|
:style="[styleItem.style.imageUrl ? { backgroundImage:'url(' + styleItem.style.imageUrl + ')'} : itemStyle ]"
|
|
class="c-style-thumb"
|
|
>
|
|
<span class="c-style-thumb__text"
|
|
:class="{ 'hide-nice': !hasProperty(styleItem.style.color) }"
|
|
>
|
|
ABC
|
|
</span>
|
|
</div>
|
|
|
|
<toolbar-color-picker v-if="hasProperty(styleItem.style.border)"
|
|
class="c-style__toolbar-button--border-color u-menu-to--center"
|
|
:options="borderColorOption"
|
|
@change="updateStyleValue"
|
|
/>
|
|
<toolbar-color-picker v-if="hasProperty(styleItem.style.backgroundColor)"
|
|
class="c-style__toolbar-button--background-color u-menu-to--center"
|
|
:options="backgroundColorOption"
|
|
@change="updateStyleValue"
|
|
/>
|
|
<toolbar-color-picker v-if="hasProperty(styleItem.style.color)"
|
|
class="c-style__toolbar-button--color u-menu-to--center"
|
|
:options="colorOption"
|
|
@change="updateStyleValue"
|
|
/>
|
|
<toolbar-button v-if="hasProperty(styleItem.style.imageUrl)"
|
|
class="c-style__toolbar-button--image-url"
|
|
:options="imageUrlOption"
|
|
@change="updateStyleValue"
|
|
/>
|
|
<toolbar-toggle-button v-if="hasProperty(styleItem.style.isStyleInvisible)"
|
|
class="c-style__toolbar-button--toggle-visible"
|
|
:options="isStyleInvisibleOption"
|
|
@change="updateStyleValue"
|
|
/>
|
|
</div>
|
|
|
|
<!-- Save Styles -->
|
|
<toolbar-button v-if="canSaveStyle"
|
|
class="c-style__toolbar-button--save c-local-controls--show-on-hover c-icon-button c-icon-button--major"
|
|
:options="saveOptions"
|
|
@click="saveItemStyle()"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import ToolbarColorPicker from "@/ui/toolbar/components/toolbar-color-picker.vue";
|
|
import ToolbarButton from "@/ui/toolbar/components/toolbar-button.vue";
|
|
import ToolbarToggleButton from "@/ui/toolbar/components/toolbar-toggle-button.vue";
|
|
import {STYLE_CONSTANTS} from "@/plugins/condition/utils/constants";
|
|
import {getStylesWithoutNoneValue} from "@/plugins/condition/utils/styleUtils";
|
|
|
|
export default {
|
|
name: 'StyleEditor',
|
|
components: {
|
|
ToolbarButton,
|
|
ToolbarColorPicker,
|
|
ToolbarToggleButton
|
|
},
|
|
inject: ['openmct'],
|
|
props: {
|
|
isEditing: {
|
|
type: Boolean,
|
|
required: true
|
|
},
|
|
mixedStyles: {
|
|
type: Array,
|
|
default() {
|
|
return [];
|
|
}
|
|
},
|
|
nonSpecificFontProperties: {
|
|
type: Array,
|
|
required: true
|
|
},
|
|
styleItem: {
|
|
type: Object,
|
|
required: true
|
|
}
|
|
},
|
|
computed: {
|
|
itemStyle() {
|
|
return getStylesWithoutNoneValue(this.styleItem.style);
|
|
},
|
|
borderColorOption() {
|
|
let value = this.styleItem.style.border.replace('1px solid ', '');
|
|
|
|
return {
|
|
icon: 'icon-line-horz',
|
|
title: STYLE_CONSTANTS.borderColorTitle,
|
|
value: this.normalizeValueForSwatch(value),
|
|
property: 'border',
|
|
isEditing: this.isEditing,
|
|
nonSpecific: this.mixedStyles.indexOf('border') > -1
|
|
};
|
|
},
|
|
backgroundColorOption() {
|
|
let value = this.styleItem.style.backgroundColor;
|
|
|
|
return {
|
|
icon: 'icon-paint-bucket',
|
|
title: STYLE_CONSTANTS.backgroundColorTitle,
|
|
value: this.normalizeValueForSwatch(value),
|
|
property: 'backgroundColor',
|
|
isEditing: this.isEditing,
|
|
nonSpecific: this.mixedStyles.indexOf('backgroundColor') > -1
|
|
};
|
|
},
|
|
colorOption() {
|
|
let value = this.styleItem.style.color;
|
|
|
|
return {
|
|
icon: 'icon-font',
|
|
title: STYLE_CONSTANTS.textColorTitle,
|
|
value: this.normalizeValueForSwatch(value),
|
|
property: 'color',
|
|
isEditing: this.isEditing,
|
|
nonSpecific: this.mixedStyles.indexOf('color') > -1
|
|
};
|
|
},
|
|
imageUrlOption() {
|
|
return {
|
|
icon: 'icon-image',
|
|
title: STYLE_CONSTANTS.imagePropertiesTitle,
|
|
dialog: {
|
|
name: "Image Properties",
|
|
sections: [
|
|
{
|
|
rows: [
|
|
{
|
|
key: "url",
|
|
control: "textfield",
|
|
name: "Image URL",
|
|
"cssClass": "l-input-lg"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
property: 'imageUrl',
|
|
formKeys: ['url'],
|
|
value: {url: this.styleItem.style.imageUrl},
|
|
isEditing: this.isEditing,
|
|
nonSpecific: this.mixedStyles.indexOf('imageUrl') > -1
|
|
};
|
|
},
|
|
isStyleInvisibleOption() {
|
|
return {
|
|
value: this.styleItem.style.isStyleInvisible,
|
|
property: 'isStyleInvisible',
|
|
isEditing: this.isEditing,
|
|
options: [
|
|
{
|
|
value: '',
|
|
icon: 'icon-eye-disabled',
|
|
title: STYLE_CONSTANTS.visibilityHidden
|
|
},
|
|
{
|
|
value: STYLE_CONSTANTS.isStyleInvisible,
|
|
icon: 'icon-eye-open',
|
|
title: STYLE_CONSTANTS.visibilityVisible
|
|
}
|
|
]
|
|
};
|
|
},
|
|
saveOptions() {
|
|
return {
|
|
icon: 'icon-save',
|
|
title: 'Save style',
|
|
isEditing: this.isEditing
|
|
};
|
|
},
|
|
canSaveStyle() {
|
|
return this.isEditing && !this.mixedStyles.length && !this.nonSpecificFontProperties.length;
|
|
}
|
|
},
|
|
methods: {
|
|
hasProperty(property) {
|
|
return property !== undefined;
|
|
},
|
|
normalizeValueForSwatch(value) {
|
|
if (value && value.indexOf('__no_value') > -1) {
|
|
return value.replace('__no_value', 'transparent');
|
|
}
|
|
|
|
return value;
|
|
},
|
|
normalizeValueForStyle(value) {
|
|
if (value && value === 'transparent') {
|
|
return '__no_value';
|
|
}
|
|
|
|
return value;
|
|
},
|
|
updateStyleValue(value, item) {
|
|
value = this.normalizeValueForStyle(value);
|
|
if (item.property === 'border') {
|
|
value = '1px solid ' + value;
|
|
}
|
|
|
|
if (value && (value.url !== undefined)) {
|
|
this.styleItem.style[item.property] = value.url;
|
|
} else {
|
|
this.styleItem.style[item.property] = value;
|
|
}
|
|
|
|
this.$emit('persist', this.styleItem, item.property);
|
|
},
|
|
saveItemStyle() {
|
|
this.$emit('save-style', this.itemStyle);
|
|
}
|
|
}
|
|
};
|
|
</script>
|