import "./index.scss"; import React = require("react"); import cx = require("classnames"); import { CSSUnitInputComponent } from "./common"; import { BaseApplicationComponent } from "@tandem/common"; import { MetadataKeys } from "@tandem/editor/browser/constants"; import { RadioGroupComponent, TextInputComponent } from "@tandem/uikit"; import { ChromePicker } from "react-color"; import AutoSizeInput = require("react-input-autosize"); import ReactSliderComponent = require("react-slider"); import { CSSMergedRuleLinkComponent, CSSHighlightTargetRuleHintComponent } from "../common"; import Select = require("react-select"); import CheckboxComponent = require("rc-checkbox"); import { capitalize, startCase } from "lodash"; import { SUPPORTED_FONTS } from "@tandem/html-extension/editor/browser/constants"; import { parseCSSDeclValue, SyntheticCSSColor, SyntheticCSSStyle, SyntheticCSSFilter, SyntheticAmountFilter, SyntheticDropShadowFilter, getCSSFontFaceRules, SyntheticCSSFontFace, evaluateCSSDeclValue, SyntheticHTMLElement, SyntheticCSSStyleGraphics, SyntheticCSSStyleBoxShadow, SyntheticCSSStyleBackground, SyntheticCSSElementStyleRule, } from "@tandem/synthetic-browser"; import { MergedCSSStyleRule } from "@tandem/html-extension/editor/browser/stores"; // http://www.w3schools.com/csSref/pr_class_display.asp const DISPLAY_OPTIONS = ["block", "inline", "inline-block", "flex", "none", "table"].map((value) => { return { label: value, value: value }; }); // https://css-tricks.com/snippets/css/a-guide-to-flexbox/ const FLEX_DIRECTION_OPTIONS = ["row", "column"].map((value) => { return { label: value, value: value }; }); const FLEX_WRAP_OPTIONS = ["nowrap", "wrap", "wrap-reverse"].map((value) => { return { label: value, value: value }; }); const FLEX_FLOW_OPTIONS = ["start", "end", "center", "space-bwtween", "space-around"].map((value) => { return { label: value, value: value }; }); const FLEX_JUSTIFY_CONTENT_OPTIONS = ["flex-start", "flex-end", "center", "space-between", "space-around"].map((value) => { return { label: value, value: value }; }); const FLEX_ALIGN_ITEMS_OPTIONS = ["flex-start", "flex-end", "center", "baseline"].map((value) => { return { label: value, value: value }; }); const FLEX_ALIGN_CONTENT_OPTIONS = ["flex-start", "flex-end", "center", "space-between", "space-around", "stretch"].map((value) => { return { label: value, value: value }; }); // http://www.w3schools.com/css/css_positioning.asp const POSITION_OPTIONS = ["static", "relative", "fixed", "absolute"].map((value) => { return { label: value, value: value }; }); // http://www.w3schools.com/cssref/pr_background-blend-mode.asp const BLEND_MODE_OPTIONS = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "saturation", "color", "lumocity"].map((value) => { return { label: value, value: value }; }); // http://www.w3schools.com/cssref/pr_background-blend-mode.asp const TEXT_ALIGN_OPTIONS = ["left", "center", "right", "justify"].map((value) => { return { label: value, value: value }; }); // http://www.w3schools.com/cssref/pr_background-blend-mode.asp const TEXT_DECOR_OPTIONS = ["none", "underline", "overline", "line-through"].map((value) => { return { label: value, value: value }; }); const DEFAULT_FONT_FAMILY_OPTIONS = SUPPORTED_FONTS.map((value) => { return { label: value, value: value }; }); const BACKGROUND_REPEAT_OPTIONS = ["repeat", "repeat-x", "repeat-y", "no-repeat"].map((value) => { return { label: value, value: value }; }); const WORD_WRAP_OPTIONS = ["normal", "break-word", "initial"].map((value) => { return { label: value, value: value }; }); const TEXT_OVERFLOW_OPTIONS = ["initial", "ellipsis", "clip"].map((value) => { return { label: value, value: value }; }); const WHITE_SPACE_OPTIONS = ["normal", "nowrap", "pre", "pre-line", "pre-wrap"].map((value) => { return { label: value, value: value }; }); const LAYOUT_OVERFLOW_OPTIONS = ["visible", "hidden", "scroll"].map((value) => { return { label: value, value: value }; }); const FLOAT_OPTIONS = ["none", "left", "right", "inline-start", "inline-end"].map((value) => { return { label: value, value: value }; }); const FONT_STYLE_OPTIONS = ["normal", "italic", "oblique", "initial"].map((value) => { return { label: value, value: value }; }); const CSS_FILTER_OPTIONS = ["blur", "brightness", "contrast", "drop-shadow", "grayscale", "hue-rotate", "invert", "opacity", "saturate", "sepia"].map((value) => { return { label: value, value: value }; }); const TEXT_TRANSFORM_OPTIONS = ["none", "uppercase", "lowercase", "capitalize"].map((value) => { return { label: value, value: value }; }); const DISPLAY_PREVIEWS = { block: () => { return
Lorem
ipsum
dolar
sit
}, inline: () => { return
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In velit.
}, "inline-block": () => { return
Lorem
ipsum
dolar
sit
}, "flex": () => { return
} } const FLEX_ALIGN_ITEMS_PREVIEWS = { } const FLEX_ALIGN_CONTENT_PREVIEWS = { } const FLEX_DIRECTION_PREVIEWS = { row: () => { return
}, column: () => { return
} } const FLEX_WRAP_PREVIEWS = { } const createPreviewMenuOption = (previewRenderers: any) => { return (option) => { return { option.label } } } export class CSSPrettyInspectorComponent extends BaseApplicationComponent<{ rule: MergedCSSStyleRule, graphics: SyntheticCSSStyleGraphics }, any> { render() { const { rule } = this.props; const graphics = rule.graphics; // //
return
{ this.renderAppearance() }
{ this.renderAnimations() }
} renderAppearance() { const { rule, graphics } = this.props; return
Opacity
Blend
Position
Float
Wrap
} renderAdvancedSection = () => { const { rule } = this.props; return
Align items
} } class FlexContainerChildSectionComponent extends SectionComponent { componentDidMount() { // if (process.env.SANDBOXED) { // this.openPopup("Advanced", this.renderAdvancedSection); // } } renderMainSection() { // OTHERS - align-self, flex, flex-basis const { graphics, rule } = this.props; // yuck - checking computed property here just to get it to work if (!rule.target.parentElement || ((rule.target.parentElement as SyntheticHTMLElement).getComputedStyle() || {} as any).display !== "flex") return null; return
Flex Child
Grow
Shrink
Order
; // if (!rule.target.parentNode || rule.target.parentNode) return null; } } class TypographySectionComponent extends SectionComponent { componentDidMount() { // if (process.env.SANDBOXED) { // this.openPopup("Advanced", this.renderAdvancedSection); // } } // TODO - implement this previewFont = (option) => { // if (option == null) { // this.props.rule.getTargetRule("fontFamily").style.setProperty("fontFamily", this.props.rule.style.fontFamily); // } else { // console.log(this.props.rule.getTargetRule("fontFamily").style); // this.props.rule.getTargetRule("fontFamily").style.setProperty("fontFamily", option.value); // } } renderMainSection() { const { rule, graphics } = this.props; // TODO - preview font on key down const renderFontOption = (option) => { return { option.label } }; return
Typography
{ this.openPopup("Advanced", this.renderAdvancedSection); }} />
Font
Overflow
Decoration
Transform
Blend
{ if (option) this.props.rename(filter, (option as any).value); }} />
} renderInput(name: string, params: any[]) { return {}} /> } } class BackgroundFillComponent extends React.Component<{ value: string, onClick?: () => any }, any> { render() { const { value } = this.props; return
} }