? Pending

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
20 Mar 2018

Pull Request for Issue #19943 .

Summary of Changes

Makes the "type" detection for the switcher more robust.
Currently, everything behind the class part "switcher-" becomes the "type" of the switcher. This PR changes it so only that class is taken into account and following additional classes are ignored.

Testing Instructions

Adjust a radio field with class "switcher", eg https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_content/config.xml#L22.

  • Add to the existing class a second one like switcher-danger making it class="switcher switcher-danger". Then test the appearance in the com_content option page.
  • Change that class attribute again to something like class="switcher btn-group" and check again.

Expected result

First test should change the switcher to a red one instead of green.
Second test should change nothing (since no switcher-foo is defined). Your switcher should stay green.

Actual result

First test works as expected and switcher gets red.
Second test changes the switcher to use no color at all.

Documentation Changes Required

None

avatar Bakual Bakual - open - 20 Mar 2018
avatar Bakual Bakual - change - 20 Mar 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 20 Mar 2018
Category Layout
avatar Bakual
Bakual - comment - 20 Mar 2018

Btw possible values as far as I know are switcher-success (default one), switcher-warning and switcher-danger. Maybe there are additional ones (@dgt41 is that documented?)

avatar Bakual Bakual - change - 20 Mar 2018
Title
Make switcher type detection more robust
[4.0] Make switcher type detection more robust
avatar Bakual Bakual - edited - 20 Mar 2018
avatar astridx
astridx - comment - 21 Mar 2018

@Bakual Thank you.

I have tested this item successfully on 2705963

I tested the design in Joomla 4 not the functionality.

I did not apply any class attribute: I saw no swicher, but circels and the field works. I could change die active circles

<field
	name="article_layout"
	type="componentlayout"
	label="JGLOBAL_FIELD_LAYOUT_LABEL"
	menuitems="true"
	extension="com_content"
	view="article"
/>

With class=switcher-danger (without switcher) the switcher color is green. I expected a red color, but that is OK. I forgot to insert the switcher to the class list.

<field
	name="show_title"
	type="radio"
	label="JGLOBAL_SHOW_TITLE_LABEL"
	class="switcher-danger"
	default="1"
	>
	<option value="0">JHIDE</option>
	<option value="1">JSHOW</option>
</field>

With class=switcher switcher-danger the switcher color is green like expected.

<field
	name="show_title"
	type="radio"
	label="JGLOBAL_SHOW_TITLE_LABEL"
	class="switcher switcher-danger"
	default="1"
	>
	<option value="0">JHIDE</option>
	<option value="1">JSHOW</option>
</field>

With class=switcher switcher-primary the switcher color is blue like expected

<field
	name="show_title"
	type="radio"
	label="JGLOBAL_SHOW_TITLE_LABEL"
	class="switcher switcher-primary"
	default="1"
	>
	<option value="0">JHIDE</option>
	<option value="1">JSHOW</option>
</field>

Is there a documentation anywhere for this webcomponent?

avatar astridx astridx - test_item - 21 Mar 2018 - Tested successfully
avatar dgt41
dgt41 - comment - 21 Mar 2018

@Bakual I believe that the 4 cookouts that are used in alerts (blue, green, yellow, red) cover 90% of the use cases but Charlie is against that.

Anyways whatever the decision on the number of colors supported by the switcher there is fine detail that needs to be taken into consideration: custom elements WILL be again 1 file so the idea of extending the css means also that people will have to override (totally doable right now) the js!

@wilsonge can you merge this?

avatar C-Lodder
C-Lodder - comment - 21 Mar 2018

@Bakual We currently use the following colour map for custom elements:

$theme-colors: map-merge((
        primary: $blue,
        secondary: $gray-600,
        success: $green,
        warning: $yellow,
        danger: $red
), $theme-colors);

However I may unset secondary and warning for the switcher

@dgt41 I assume you mean, for example, the use of alert-blue instead of alert-primary?

avatar Bakual
Bakual - comment - 16 Apr 2018

Rebased to see if tests now pass

avatar Quy
Quy - comment - 16 Apr 2018

[c/s] Add space before and after +?

avatar Bakual
Bakual - comment - 16 Apr 2018

@Quy I don't even know if we have a CS rule for that but I can do that of course.

eebce42 16 Apr 2018 avatar Bakual CS
avatar Bakual Bakual - change - 16 Apr 2018
Labels Added: ?
avatar wilsonge wilsonge - change - 2 May 2018
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-05-02 22:37:35
Closed_By wilsonge
avatar wilsonge wilsonge - close - 2 May 2018
avatar wilsonge wilsonge - merge - 2 May 2018

Add a Comment

Login with GitHub to post a comment