Skip to content

Commit 3f53ece

Browse files
janfaraciktimja
andauthored
docs: Add toggle switch page (#62)
* Init * Update icon, change samples * Cleanup for release Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
1 parent 2d75ae8 commit 3f53ece

7 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.jenkins.plugins.designlibrary;
2+
3+
import hudson.Extension;
4+
5+
@Extension
6+
public class ToggleSwitch extends UISample {
7+
@Override
8+
public String getDisplayName() {
9+
return "Toggle switch";
10+
}
11+
12+
@Override
13+
public String getIconFileName() {
14+
return "symbol-toggle-switch";
15+
}
16+
17+
@Extension
18+
public static final class DescriptorImpl extends UISampleDescriptor {
19+
}
20+
}
21+
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?jelly escape-by-default='true'?>
2+
<j:jelly xmlns:j="jelly:core" xmlns:s="/lib/samples" xmlns:f="/lib/form">
3+
<s:sample>
4+
<div class="app-component-sample">
5+
<f:toggleSwitch name="enabled" title="Hello world" />
6+
</div>
7+
<pre>
8+
<code class="sample-remote language-xml" data-sample="default.jelly"/>
9+
</pre>
10+
11+
<p class="jenkins-description">You can invert the position of the label with the <code>invertLabel</code> attribute.</p>
12+
<div class="app-component-sample app-component-sample--right-alignment">
13+
<f:toggleSwitch name="enabled" title="Hello world" invertLabel="true" />
14+
</div>
15+
<pre>
16+
<code class="sample-remote language-xml" data-sample="inverted.jelly"/>
17+
</pre>
18+
19+
<h2>${%Dynamic labels}</h2>
20+
<p class="jenkins-description">Toggle switches labels can update in real time to reflect their status by setting the <code>checkTitle</code> attribute.</p>
21+
<p class="jenkins-description">Try clicking on the toggle switch below to see how this works.</p>
22+
23+
<div class="app-component-sample">
24+
<f:toggleSwitch name="enable"
25+
title="${%Disabled}"
26+
checkedTitle="${%Enabled}"
27+
checked="true"
28+
tooltip="${%Enable or disable the current project}" />
29+
</div>
30+
<pre>
31+
<code class="sample-remote language-xml" data-sample="dynamic.jelly"/>
32+
</pre>
33+
</s:sample>
34+
</j:jelly>

src/main/resources/scss/components/_component-sample.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
align-items: unset;
2424
}
2525

26+
&--right-alignment {
27+
align-items: flex-end;
28+
}
29+
2630
#bottom-sticker {
2731
margin-left: -1rem;
2832
width: calc(100% + 2rem);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<f:toggleSwitch name="enabled" title="Hello world" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<f:toggleSwitch name="enable"
2+
title="${%Disabled}"
3+
checkedTitle="${%Enabled}"
4+
checked="true"
5+
tooltip="${%Enable or disable the current project}" />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<f:toggleSwitch name="enabled" title="Hello world" invertLabel="true" />

0 commit comments

Comments
 (0)