Page MenuHomePhabricator

Codex-PHP: Add examples of checked and disabled ToggleSwitch
Closed, DeclinedPublic

Description

ToggleSwitchExample.php contains one example of a toggle switch. We should make this a group of toggle switches that demonstrates different types of toggle switches.

  • Add a toggle switch that is already checked
  • Add a disabled toggle switch
  • Verify that they show up correctly in the sandbox (composer run-script start-sandbox)
  • Regenerate the snapshot tests (composer run update-snapshots)

Event Timeline

Catrope renamed this task from Codex-PHP: Add examples of selected, disabled and inline ToggleSwitch to Codex-PHP: Add examples of checked, disabled and inline ToggleSwitch.Feb 24 2026, 7:32 PM
Catrope updated the task description. (Show Details)

Hi I am an Outreachy applicant and I'd like to work on this microtask
thanks

@Catrope When creating Inline for the toggle switch, it gives me Call to unknown method: Wikimedia\Codex\Builder\ToggleSwitchBuilder::setInline()
searched for references https://doc.wikimedia.org/design-codex-php/main/functions_s.html and inline doesnt support toggle switch builder

@Catrope moreover if one needs to add inline styling to the default component itself
how must that be

  1. [label] switch [description]

2.[label]

switch

[description]

Hi @Rishannn,
To achieve inline styling for the component itself, I considered:

Wrapping the toggle switch in a container and apply the desired inline classes there like this ->setWrapperAttributes(['style' => 'display:flex; align-items:center; gap:8px;'])

If the inline styling needs to be applied frequently, another option is to extend the ToggleSwitchBuilder to accept inline layout classes. You can explore that approach if needed.

Change #1257268 had a related patch set uploaded (by Vanessa_bedzra; author: Vanessa_bedzra):

[design/codex-php@main] OUTREACHY-T418300:Codex-PHP: Add examples of checked, disabled and inline ToggleSwitch

https://gerrit.wikimedia.org/r/1257268

thanks @Vanny , but first the css version should get the inline property , then we can bring it to the php
im happy to make the change first to css version then to the php one

( this ->setWrapperAttributes(['style' => 'display:flex; align-items:center; gap:8px;']) )
this workaround is great , but developers may need consistency and better portability between the two

will be very helpful if @Catrope , @Aklapper would suggest which will be good

I agree with @Rishannn and @Vanny setInline() doesn't exist in ToggleSwitchBuilder.php. After checking the codebase, implementing it properly would require changes to the builder, renderer and mustache template. Should I go ahead and make these changes @Catrope?

Change #1258014 had a related patch set uploaded (by EileenBlessing; author: EileenBlessing):

[design/codex-php@main] T418300: Added checked and disabled ToggleSwitch

https://gerrit.wikimedia.org/r/1258014

I have added checked and disabled toggle switch examples. The patch can be found here: https://gerrit.wikimedia.org/r/c/design/codex-php/+/1258014

Change #1258014 had a related patch set uploaded (by EileenBlessing; author: EileenBlessing):

[design/codex-php@main] sandbox: Add checked and disabled ToggleSwitch

https://gerrit.wikimedia.org/r/1258014

Change #1257268 had a related patch set uploaded (by Vanessa_bedzra; author: Vanessa_bedzra):

[design/codex-php@main] Add examples of checked, disabled, and inline ToggleSwitch

https://gerrit.wikimedia.org/r/1257268

Change #1257268 had a related patch set uploaded (by Vanessa_bedzra; author: Vanessa_bedzra):

[design/codex-php@main] T418300: Add examples of checked, disabled, and inline ToggleSwitch

https://gerrit.wikimedia.org/r/1257268

Change #1258130 had a related patch set uploaded (by ItoroJames; author: ItoroJames):

[design/codex-php@main] T418300: Add examples of checked and disabled ToggleSwitch

https://gerrit.wikimedia.org/r/1258130

Hi, I've submitted a patch implementing the checked and disabled ToggleSwitch examples:

https://gerrit.wikimedia.org/r/c/design/codex-php/+/1258130

Regarding the inline example after investigating the codebase I found that:

  1. ToggleSwitchBuilder has no setInline() method (unlike Checkbox and Radio which do)
  2. The Mustache template has no isInline variable
  3. cdx-toggle-switch--inline CSS class does not exist in the Codex stylesheet

Adding inline support would require changes to both design/codex-php (PHP/template)
and design/codex (CSS/Vue).

Hi,

My name is Joy an Outreachy internship applicant and I'll like to work on this issue T418300.

Can I be assigned to it.

Thanks

Catrope renamed this task from Codex-PHP: Add examples of checked, disabled and inline ToggleSwitch to Codex-PHP: Add examples of checked and disabled ToggleSwitch.Mon, Mar 23, 11:50 PM
Catrope updated the task description. (Show Details)

Change #1258130 had a related patch set uploaded (by ItoroJames; author: ItoroJames):

[design/codex-php@main] T418300: Add examples of checked and disabled ToggleSwitch

https://gerrit.wikimedia.org/r/1258130

Change #1260015 had a related patch set uploaded (by ItoroJames; author: ItoroJames):

[design/codex-php@main] sandbox: Wrap ToggleSwitch examples in block elements

https://gerrit.wikimedia.org/r/1260015

Change #1265395 had a related patch set uploaded (by Chimaobi98; author: Chimaobi98):

[design/codex-php@main] ToggleSwitchExample: Add checked and disabled toggle switch examples

https://gerrit.wikimedia.org/r/1265395

LGoto subscribed.

Thanks to all the candidates who showed an interest in this project. Unfortunately, due to changing circumstances, the mentor team is no longer able to move forward with this project proposal. We appreciate all the work that’s been put into this already, and wish all the candidates the best in your future work.

Change #1258130 abandoned by VolkerE:

[design/codex-php@main] T418300: Add examples of checked and disabled ToggleSwitch

Reason:

Thanks for your contribution, this was a good attempt! Another candidate was first in the response and followed-up in best manner. Please see I2a24f37aff for reference. Best regards.

https://gerrit.wikimedia.org/r/1258130

Change #1258014 abandoned by VolkerE:

[design/codex-php@main] sandbox: Add checked and disabled ToggleSwitch

Reason:

Hi, preferring on this task slightly I2a24f37aff although both of your attempts were good quality. Other candidate was just slightly faster. Thanks again!

https://gerrit.wikimedia.org/r/1258014

Change #1260015 abandoned by VolkerE:

[design/codex-php@main] sandbox: Wrap ToggleSwitch examples in block elements

Reason:

Thanks for the contribution. The block element wrapping should happen in the demo update Git commit. We go with I2a24f37aff2 for reference. Best regards!

https://gerrit.wikimedia.org/r/1260015

Change #1265395 abandoned by VolkerE:

[design/codex-php@main] ToggleSwitchExample: Add checked and disabled toggle switch examples

Reason:

Thanks for your contribution! We go ahead with I2a24f37aff2f for your reference. While this is of reasonable quality, the other candidate's patch was received earlier and has been quickly brought on par with our coding conventions and quality expectations. Best regards

https://gerrit.wikimedia.org/r/1265395

Change #1257268 merged by jenkins-bot:

[design/codex-php@main] sandbox: Add examples of checked and disabled ToggleSwitch

https://gerrit.wikimedia.org/r/1257268