Issue #2990Opened September 1, 2020by Joshmamroud0 reactions

QUESTION: Is there a way to use different variations of the same style property?

Question

Note: This is in the context of the Style Manager.

Is there a way to use different variations of the same style property?

For example when I use the text-align property on a non-text node component I'd like the label to read "Align Content" with the options of "left", "right" and "center". However, when the "text-align" property is displayed for a text node I'd like the label to read "Align Text" with the options of "left", "right", "center", and "justify".

I've searched the documentation and issues on GitHub and can't seem to find any answers.

Does anyone know how to achieve this?

Thanks in advance!

Answers (3)

Ju99ernautSeptember 5, 20200 reactions

I don't think that's possible using the API, also does text-align work for non-text components? You'll probably want to use the align-content property from flexbox

artfSeptember 8, 20200 reactions

You should try to use Component's stylable-require property to show the particular style property (marked with toRequire) and unstylable for the one you don't need.

editor.Components.addType('...', {
 model: {
  defaults: {
   'stylable-require': ['align-content'],
   unstylable: ['text-align'],
  }
 }
});

// in your StyleManager configuration
buildProps: [..., 'text-align', 'align-content'],
properties: [{
       // ...
        property: 'align-content',
        toRequire: true, // <-- So this property will be hidden if the component doesn't require it
}]
JoshmamroudSeptember 8, 20200 reactions

@artf Thank you for your response.

In this case, I would still have an issue using the align-content property with flex columns and rows. For columns, I'd like the options to read: Top, Center, and Bottom and for rows I'd like the options to read: Left, Center, and Right.

My users aren't too familiar with CSS let alone flexbox and to use Start, Center and End won't be as good of a user experience as I'd like.

Do you have any other suggestions?

Thank you, Josh

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.