Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spacing & Typography fields' output CSS doesn't support value_pattern, prefix, suffix #1183

Closed
daviedR opened this issue Dec 4, 2016 · 5 comments

Comments

@daviedR
Copy link

daviedR commented Dec 4, 2016

Hi Ari,

Why Spacing & Typography fields output CSS doesn't support value_pattern, prefix, and suffix?
We might want to add !important as suffix, or maybe calc() as the value_pattern.

@aristath aristath modified the milestone: 2.4.0 Dec 10, 2016
@aristath aristath self-assigned this Dec 18, 2016
@aristath
Copy link
Contributor

This one is a bit weird...

Those are fields that return arrays of values.
The spacing control should work, I agree. that one is a bug.
However, on the typography field things get a bit more complicated.
The problem is that the arguments are passed-on to all properties.
suffix & prefixes will be added to font-size, line-height, font-family and so on.
Value_pattern would mess font-families completely and would only make sense in some of the control's sub-values.

Any ideas on how we could differentiate those and make things more modular?
I'm open to suggestions, but I also don't want this to get too complicated... The KISS rule applies everywhere.

@Jaessun
Copy link

Jaessun commented Mar 7, 2017

Hi,

I stumbled across this issue as I too would like to use value_pattern with the typography field and thought of a solution:

As the theme_mod for the typography field is an array of key-values, couldn't we use the placeholder in the value_pattern like an array?

Say for example that I want to calculate the font-size, then it would look like this:

'output' => array(
    array(
        'element' => '.my-element'
    ),
    array(
        'element' => '.my-element',
        'property' => 'font-size',
        'value-pattern' => "calc($['font-size']em / 2)"
    ),
);

All the typography properties would apply to .my-element like normal except the font-size that is overridden with the value_pattern.

I don't know if it would be easy to implement or even simple enough to respect the KISS but keep in mind this is a simple suggestion.

@aristath
Copy link
Contributor

aristath commented May 27, 2017

Fixed in 3.0

You should now be able to use something like this:

'output' => array(
	array(
		'element' => '.my-element'
	),
	array(
		'element'       => '.my-element2',
		'property'      => 'font-size',
		'value_pattern' => 'calc($ / 2)',
		'choice'        => 'font-size',
	),
);

@bawright
Copy link

bawright commented Jun 11, 2017

Hey @aristath, choice is working, but I'm not able to get the value-pattern part of this working.

Also, any particular reason why you're using value-pattern instead of value_pattern for consistency?

@aristath
Copy link
Contributor

That was just a typo, fixed it in the above comment.
Try using value_pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants