forked from syncfusion/ej2-aspnetmvc-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustom.cshtml
268 lines (251 loc) · 8.87 KB
/
Custom.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
@using Syncfusion.EJ2
@section ControlsSection{
<div class="control-section">
<div id="custom-control">
<div class="row">
<div id="e-shirt-preview"></div>
</div>
<div id="custom-content" id="colorpicker-content" class="row">
<div class="col-xs-12 col-sm-12 col-lg-6 col-md-6 e-circle-wrap">
@Html.EJS().ColorPicker("circle-palette").Mode(Syncfusion.EJ2.Inputs.ColorPickerMode.Palette).ModeSwitcher(false).Inline(true).ShowButtons(false).Columns(4).BeforeTileRender("beforeCircleTileRender").PresetColors(@ViewBag.circlePaletteColors).Change("onChange").Render()
</div>
<div class="col-xs-12 col-sm-12 col-lg-6 col-md-6 e-rounded-wrap">
@Html.EJS().ColorPicker("rounded-palette").Mode(Syncfusion.EJ2.Inputs.ColorPickerMode.Palette).ModeSwitcher(false).Inline(true).ShowButtons(false).Columns(5).BeforeTileRender("beforeRoundedTileRender").PresetColors(@ViewBag.roundedPaletteColors).Change("roundedPaletteChange").Render()
</div>
<div class="col-xs-12 col-sm-12 col-lg-6 col-md-6 e-square-wrap">
@Html.EJS().ColorPicker("square-palette").Mode(Syncfusion.EJ2.Inputs.ColorPickerMode.Palette).ModeSwitcher(false).Inline(true).ShowButtons(false).Columns(8).BeforeTileRender("beforeSquareTileRender").PresetColors(@ViewBag.squarePaletteColors).Change("onChange").Render()
</div>
<div class="col-xs-12 col-sm-12 col-lg-6 col-md-6 e-scroll-wrap">
@Html.EJS().ColorPicker("scroll-palette").Mode(Syncfusion.EJ2.Inputs.ColorPickerMode.Palette).ModeSwitcher(false).Inline(true).ShowButtons(false).Columns(4).BeforeTileRender("beforeScrollTileRender").PresetColors(@ViewBag.scrollPaletteColors).Change("onChange").Render()
</div>
</div>
</div>
</div>
}
@section Meta{
<meta name="description" content="This example demonstrates the Custom Palettes in ASP.NET MVC Color Picker control. Explore here for more details."/>
}
@section ActionDescription{
<div id="action-description">
<p>This sample demonstrates how to customize the color palettes with different types and styles.</p>
</div>
}
@section Description{
<div id="description">
<p>
The ColorPicker component is a user interface to select and adjust color values. This supports various color specifications
like RGB (Red Green Blue), HSV (Hue Saturation Value), and Hex codes.
</p>
<p>
In this sample,</p>
<ul>
<li>
Select the shirt color from different customized palettes. It contains circle, square, rounded edge, and multiple
scroll palettes.
</li>
<li>Using the
<code>
<a target="_blank" class="code" href="https://help.syncfusion.com/cr/cref_files/aspnetmvc-js2/Syncfusion.EJ2~Syncfusion.EJ2.Inputs.ColorPicker~PresetColors.html">presetColors
</a>
</code> property, you can specify the custom colors to be loaded.</li>
</ul>
<p>
More information about ColorPicker can be found in this
<a target="_blank" href="https://ej2.syncfusion.com/aspnetmvc/documentation/color-picker/how-to/customize-colorpicker/">
documentation section</a>.
</p>
</div>
}
@*custom code start*@
@section Scripts {
<script>
if (window.browserDetails.isDevice) {
document.getElementById('custom-control').classList.add('e-mobile-control');
}
</script>
}
@*custom code end*@
<script>
function onChange(args) {
document.getElementById('e-shirt-preview').style.backgroundColor = args.currentValue.hex;
}
function beforeCircleTileRender(args) {
args.element.classList.add('e-circle-palette');
args.element.appendChild(ej.base.createElement('span', { className: 'e-circle-selection' }));
}
function beforeSquareTileRender(args) {
args.element.classList.add('e-square-palette');
}
function beforeRoundedTileRender(args) {
args.element.classList.add('e-rounded-palette');
}
function beforeScrollTileRender(args) {
args.element.classList.add('e-icons');
args.element.classList.add('e-scroll-palette');
}
function roundedPaletteChange(args) {
this.element.nextElementSibling.querySelector('.e-selected').style.boxShadow
= args.currentValue.hex + ' 0 0 4px';
document.getElementById('e-shirt-preview').style.backgroundColor = args.currentValue.hex;
}
</script>
@*custom code start*@
<style>
/* Common sample level styles */
#custom-control {
margin: auto 0;
text-align: center;
}
#custom-control .col-lg-6 {
margin-bottom: 20px;
}
#custom-control .col-lg-6.e-circle-wrap {
width: 26%;
}
#custom-control .col-lg-6.e-square-wrap {
margin-top: 37px;
width: 22%;
}
#custom-control .col-lg-6.e-rounded-wrap {
margin-top: 35px;
width: 20%;
}
#custom-control .col-lg-6.e-scroll-wrap {
width: 32%;
}
/* Preview area styles */
#custom-control #e-shirt-preview {
background: transparent url('@Url.Content("~/Content/colorpicker/images/shirt.png")') no-repeat;
height: 320px;
margin: 20px auto;
display: inline-block;
width: 400px;
background-color: rgb(244, 67, 54);
}
#custom-control.e-mobile-control #e-shirt-preview {
margin-left: -21%;
width: 320px;
}
.highcontrast #custom-control #e-shirt-preview {
background: transparent url('@Url.Content("~/Content/colorpicker/images/shirt_highcontrast.png")') no-repeat;
background-color: rgb(244, 67, 54);
}
/* Common sample level styles for mobile */
#custom-control.e-mobile-control .col-lg-6 {
width: 55%;
}
@@media only screen and (min-width: 768px) {
#custom-control.e-mobile-control .col-sm-12 {
width: 25%;
}
}
#custom-control.e-mobile-control #custom-content {
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
}
#custom-control.e-mobile-control #custom-content .col-xs-12 {
flex: 0 0 auto;
}
</style>
@*custom code end*@
<style>
/* Circle palette customization */
.e-container .e-palette .e-circle-palette {
border: 0;
height: 32px;
width: 32px;
border-radius: 20px;
margin: 4px;
}
.e-bigger .e-container .e-palette .e-circle-palette {
height: 32px;
width: 32px;
}
.e-container .e-palette .e-circle-palette:hover {
box-shadow: none;
transform: scale(1.2);
transition: transform .2s ease-out;
}
.e-circle-palette .e-circle-selection {
height: 32px;
width: 32px;
border-radius: 20px;
display: inline-block;
transform: scale(0);
transition: transform 1.2s ease-in;
}
.e-circle-palette.e-selected .e-circle-selection {
transform: scale(0.8);
background-color: #fff;
transition: transform .2s ease-out;
}
#circle-palette+.e-container,
#scroll-palette+.e-container {
background-color: transparent;
border-color: transparent;
box-shadow: none;
}
/* Scrollable palette customization */
#scroll-palette+.e-container .e-custom-palette.e-palette-group,
.e-bigger #scroll-palette+.e-container .e-custom-palette.e-palette-group {
height: 125px;
}
.e-container .e-palette .e-scroll-palette {
border: 0;
color: #fff;
line-height: 24px;
font-size: 16px;
height: 24px;
width: 35px;
margin-top: 2px;
margin-left: 10px;
}
.e-bigger .e-container .e-palette .e-scroll-palette {
height: 24px;
width: 35px;
}
.e-container .e-palette .e-scroll-palette.e-selected::before {
content: '\e933';
}
.highcontrast .e-container .e-palette {
border-bottom-color: transparent;
}
/* Square palette customization */
.e-container .e-palette .e-square-palette,
.e-bigger .e-container .e-palette .e-square-palette {
width: 20px;
height: 20px;
}
#square-palette+.e-container .e-custom-palette .e-palette,
#rounded-palette+.e-container .e-custom-palette .e-palette {
padding: 5px;
}
/* Rounded corner palette customization */
.e-container .e-palette .e-rounded-palette {
border-radius: 4px;
margin: 3px;
height: 16px;
width: 16px;
}
.e-bigger .e-container .e-palette .e-rounded-palette {
height: 16px;
width: 16px;
}
.e-container .e-palette .e-rounded-palette:hover,
.e-container .e-palette .e-scroll-palette:hover {
box-shadow: none;
}
.e-container .e-palette .e-circle-palette.e-selected,
.e-container .e-palette .e-rounded-palette.e-selected,
.e-container .e-palette .e-square-palette.e-selected,
.e-container .e-palette .e-scroll-palette.e-selected {
outline: none;
}
</style>
@section Title{
<title>ASP.NET MVC Color Picker Custom Palettes Example - Syncfusion Demos </title>
}
@section Header{
<h1 class='sb-sample-text'>Example of Custom Palettes in ASP.NET MVC Color Picker Control</h1>
}