material icon indicating copy to clipboard operation
material copied to clipboard

md-switch doesn't have an option to align text

Open johnyricalde opened this issue 10 years ago • 7 comments

Right now the md-switch component only allows to have the text on the right side of the switch control switch-right-side-text

It will be nice to have the ability to set the text on the left size of the switch control switch-left-side-text

johnyricalde avatar Apr 05 '16 16:04 johnyricalde

+1

I think this is a very needed feature.

TrancaDev avatar Apr 06 '16 17:04 TrancaDev

Since the switches are typically to the right of the text, the option to configure the text placement is required for this control. We have implemented this in several places and really need this to be a standard config.

angryfatkid avatar Apr 08 '16 17:04 angryfatkid

+1

I'd be really useful to have that option

smfiorillo avatar Apr 08 '16 17:04 smfiorillo

@DevVersion I would like to submit a pull request for this issue. What is needed to put a PR together?

thielpa avatar Apr 24 '16 20:04 thielpa

@Lordnoname Awesome, looking forward to see it.

I think, we should add an attribute, which will be observed and can be interpolated.

<md-switch md-invert="isInverted"></md-switch> // Interpolated
<md-switch md-invert></md-switch> // True
<md-switch md-invert="false"></md-switch> // False

So, the postLink observes the attribute and applies changes correctly.

// On Init and on Attribute Value Change
$attrs.$observe('mdInvert', function(newValue) {
  isInverted = $mdUtil.parseAttributeBoolean(newValue);

  // Update Elements with CSS or JS 
 //  Think JS is better, to support RTL as well

 // Add a class to invert the margin / padding as well.
  element.toggleClass('_md-invert', isInverted);
});
// The CSS need to invert the margin or padding of the switch component.
&._md-invert {
  @include rtl-prop(padding-right, padding-left, PADDING);
}

If you have any further questions, let me know.

devversion avatar Apr 24 '16 20:04 devversion

+1 This would really help.

0815fox avatar Apr 25 '16 10:04 0815fox

This issue is closed as part of our ‘Surge Focus on Material 2' efforts. For details, see our forum posting @ http://bit.ly/1UhZyWs.

ThomasBurleson avatar Jun 02 '16 07:06 ThomasBurleson