-
Notifications
You must be signed in to change notification settings - Fork 114
WIP/Extended options - Add slider form control #2220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rickyosser
wants to merge
34
commits into
atk4:develop
Choose a base branch
from
rickyosser:slider_form_controller
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
26b5b66
Added Slider Form-control.
rickyosser 523826d
Added demo to input2.php.
rickyosser f20ffd5
Fixed a bunch of things regarding adding data to the array as well a…
rickyosser 1bd2d1f
Added Slider to demo.
rickyosser 2c80ee3
Code-style fixes.
rickyosser 9305eed
Code-style fixes.
rickyosser 73ded47
Code-style fixes.
rickyosser a0d5fb0
Added embryo of behat-tests.
rickyosser 1ce3092
Fixed embryo of behat-tests.
rickyosser 02d3e00
Added custom label function. It's not finished.
rickyosser 1320399
Merge branch 'slider_form_controller' of github.com:rickyosser/ui int…
rickyosser 9c54381
Behat changes.
rickyosser 2546f87
Trying to get custom labels to work.
rickyosser 641c54b
Fixed customLabels for slider.
rickyosser 62a001b
Simplification of the code.
rickyosser 91eed9e
Coding style fixes in demo.
rickyosser 27c5895
Coding style fixes in demo.
rickyosser 07790e8
Coding style fixes in demo.
rickyosser 313f118
Coding style fixes in demo.
rickyosser 3718627
Returned to using the array directly with spaces between brackets.
rickyosser 946f736
Merge branch 'atk4:develop' into slider_form_controller
rickyosser c51fe87
Fixed vertical slider for complex version.
rickyosser fe4ce8d
Merge branch 'atk4:develop' into slider_form_controller
rickyosser 03dfb2a
Added new layout for Vertical sliders. Fixed demo. Behat still needed…
rickyosser 0c0a7db
Merge branch 'slider_form_controller' of github.com:rickyosser/ui int…
rickyosser 7f5ae5a
Fixed coding-style.
rickyosser 817ddf2
Fixed coding-style.
rickyosser 7f40ad0
Fixed error in demo, checking styles.
rickyosser 99b314e
Fixed coding style, checking coding style.
rickyosser e853926
Fixed coding style, checking coding style.
rickyosser 5b68c47
Test of define.
rickyosser 48aa458
Test of define.
rickyosser faa508f
Fixes for StaticAnalysis.
rickyosser a3d8366
Fixes for StaticAnalysis.
rickyosser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Atk4\Ui\Demos; | ||
|
|
||
| use Atk4\Ui\App; | ||
| use Atk4\Ui\Form; | ||
| use Atk4\Ui\Header; | ||
|
|
||
| /** @var App $app */ | ||
| require_once __DIR__ . '/../init-app.php'; | ||
|
|
||
| Header::addTo($app, ['Sliders', 'size' => 2]); | ||
|
|
||
| $form = Form::addTo($app); | ||
|
|
||
| $form->addControl( | ||
| 'slider_simple1', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'min' => 0, | ||
| 'max' => 10, | ||
| 'step' => 1, | ||
| 'start' => 5, | ||
| 'caption' => 'Simple Slider', | ||
| ] | ||
| ); | ||
|
|
||
| $slider2 = $form->addControl( | ||
| 'slider_simple2', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'labeled' => true, | ||
| 'ticked' => true, | ||
| 'min' => 0, | ||
| 'max' => 10, | ||
| 'step' => 1, | ||
| 'start' => 5, | ||
| 'caption' => 'Blue ticked and labeled simple slider', | ||
| ] | ||
| ); | ||
| $slider2->input->addClass('blue'); // @phpstan-ignore property.notFound | ||
|
|
||
| $form->addControl( | ||
| 'slider_simple3', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'labeled' => true, | ||
| 'ticked' => true, | ||
| 'min' => 0, | ||
| 'max' => 10, | ||
| 'step' => 1, | ||
| 'start' => 5, | ||
| 'smooth' => true, | ||
| 'caption' => 'Smooth Blue ticked and labeled simple slider', | ||
| ] | ||
| ); | ||
|
|
||
| $form->addControl( | ||
| 'slider_ranged', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'labeled' => true, | ||
| 'ticked' => true, | ||
| 'min' => 0, | ||
| 'max' => 10, | ||
| 'step' => 1, | ||
| 'start' => 3, | ||
| 'end' => 6, | ||
| 'smooth' => true, | ||
| 'showThumbTooltip' => true, | ||
| 'tooltipConfig' => ['position' => 'top center', 'variation' => 'big blue'], | ||
| 'color' => 'blue', | ||
| 'caption' => 'Smooth Blue, ticked and labeled with tool-tips Ranged slider', | ||
| ] | ||
| ); | ||
|
|
||
| $form->addControl( | ||
| 'slider_custom', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'labeled' => true, | ||
| 'ticked' => true, | ||
| 'min' => 0, | ||
| 'max' => 6, | ||
| 'step' => 1, | ||
| 'start' => 2, | ||
| 'smooth' => true, | ||
| 'color' => 'green', | ||
| 'customLabels' => [ | ||
| 'XS', 'S', 'M', 'L', 'XL', '2XL', '3XL', | ||
| ], | ||
| 'caption' => 'Smooth Green, ticked and custom labeled slider', | ||
| ] | ||
| ); | ||
|
|
||
| $group = $form->addGroup( | ||
| [ | ||
| 'inline' => false, | ||
| // 'width' => 'six', | ||
| ], | ||
| ); | ||
|
|
||
| $h1 = Header::addTo($group, ['Vertical Sliders', 'size' => 3]); | ||
|
|
||
| $group->addControl( | ||
| 'slider_vertical', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'labeled' => true, | ||
| 'ticked' => true, | ||
| 'min' => 0, | ||
| 'max' => 6, | ||
| 'step' => 1, | ||
| 'start' => 2, | ||
| 'smooth' => true, | ||
| 'color' => 'red', | ||
| 'vertical' => true, | ||
| 'reversed' => true, | ||
| 'size' => 'small', | ||
| 'caption' => 'Smooth Red, ticked and vertical slider', | ||
| 'width' => 'two', | ||
| ] | ||
| ); | ||
|
|
||
| $group->addControl( | ||
| 'slider_vertical_right', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'labeled' => true, | ||
| 'ticked' => true, | ||
| 'min' => 0, | ||
| 'max' => 6, | ||
| 'step' => 1, | ||
| 'start' => 3, | ||
| 'smooth' => true, | ||
| 'color' => 'yellow', | ||
| 'vertical' => true, | ||
| 'reversed' => true, | ||
| 'verticalHeight' => 300, | ||
| 'caption' => 'Smooth yellow, ticked, sized, custom height, vertical slider', | ||
| 'width' => 'two', | ||
| ] | ||
| ); | ||
|
|
||
| $group->addControl( | ||
| 'slider_vertical_right_ranged', | ||
| [ | ||
| Form\Control\Slider::class, | ||
| 'labeled' => true, | ||
| 'ticked' => true, | ||
| 'min' => 0, | ||
| 'max' => 6, | ||
| 'step' => 1, | ||
| 'start' => 2, | ||
| 'end' => 6, | ||
| 'smooth' => true, | ||
| 'color' => 'green', | ||
| 'vertical' => true, | ||
| 'reversed' => true, | ||
| 'verticalHeight' => 400, | ||
| 'verticalRightAligned' => false, | ||
| 'size' => 'large', | ||
| 'caption' => 'Smooth green, ticked, large, custom heigth, vertical not right aligned slider', | ||
| 'width' => 'two', | ||
| ] | ||
| ); | ||
|
|
||
| $form->onSubmit(static function (Form $form) { | ||
| print_r($form->entity->get()); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checkouted this PR and my feelings are the current state is too wild:
So for now, please put this complex PR on hold and open another PR with minimal Slider impl. Just Slider class with normal/RO/disabled support and min/max value. This should be presented in
demos/form-control/input2.phpand min/max options indemos/form-control/slider.phpand tested with Behat tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi everyone, just as food for thought (courtesy of @abbadon1334) a minimal implementation of Fomantic-UI slider sample code:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rickyosser would you like to work on the first minimal implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've resumed work on this control again, I will do a less complex version but, ranged has to be in there as that is used in my application to be able to select an interval.
There are a few other options which might be interesting to add as well but that can be done after doing the simple-slider.
I will continue to maintain the more complex version as I know a few cases where this might be interesting to use. Especially with vertical sliders for building day-based rules and stuff.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm going through the options and I have some questions on what you @mvorisek want as the default (only) behaviour?
Take these examples:
Lables (Only below or above?)
Ticks or no ticks?
Custom labels (If no there is no way of setting the labels excepft for numbers).
Should the control handle setting up the classes as some need to have specific order to work?
I'll start with removing vertical slider as I'm not using it at the moment.
The reason for asking is that Slider in itself is a very potent tool to simplify and visualize an input where we have pre-defined inputs or a need to get a range within pre-defined limits. Other controls don't have that impact at all and using ie regular input controls would add a plethora of complexities to make those limits or pre-defined selections legal. Well, a simple slider replaces a dropdown in certain cases but with a more visual approach. A ranged slider could be replaced with 2 dropdowns but would not give the user a visual representation of the limits of the form. Programming those dropdowns would also be of a more complex nature than having a complex slider...
Just a couple of thoughts... :)