Skip to content
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

feat: Added a range #173

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

feat: Added a range #173

wants to merge 5 commits into from

Conversation

gotenxds
Copy link
Contributor

@gotenxds gotenxds commented Jul 15, 2017

  • [YUP] read and followed the CONTRIBUTING.md guide.
  • [YUP] linted, built and tested the changes locally.
  • [YUP] added/updated any applicable API documentation.
  • [YUP] added/updated any applicable demos.

Hi, I needed a range component for angular with semantic ui and it seems like it will take a while (since 2014)
for semantic-ui to get this done so I thought I'l just make one for now and we can change it when the time comes.

This is a port from https://github.com/tyleryasaka/semantic-ui-range
The same repo semantic-ui is considering working with so it should make it easier to change in the future.

This supports min and max, a step value to determine the amount to skip, a readonly that disables the ui and stops incoming value changes.

It supports touch events as well.

@gotenxds gotenxds changed the title Added a range feat: Added a range Jul 15, 2017
@edcarroll
Copy link
Owner

Thank you for the PR! 😄 🎉

I've got a busy week coming up but will try to get around to reviewing it in the next few days. A range component is definitely something I'd like to get in!

Btw, does this support vertical orientation?

Lastly a quick note, please follow the commit message rules in the contributing guide, as I may be enabling automatic releasing in the future. For now though when I merge this I will squash your commits.

@gotenxds
Copy link
Contributor Author

Hi @edcarroll !
Thanks for replying, This does not support vertical orientation but that's a good idea so I might add this in the future.

Yes I'm embarrassed to say that I read the section about commits after I already committed my work and I cant change the messages after the fact, I'l make sure to work accordingly in future commits. :)

@edcarroll
Copy link
Owner

No worries re commit messages, have done the same a few times myself!!

So I had a browse through the repo you're porting and there is a link to a vertical slider implementation - I wonder if that could be a starting point?

I'm very keen to get horizontal and vertical functionality in before merging, as I'd imagine this would be one of the major initial feature requests!

Things have been super busy at work, but I should be able to look at this day after tomorrow, or failing that the start of the weekend. Thank you for your patience 😄

@gotenxds
Copy link
Contributor Author

I see, I'll try and take a look, I have a busy weekend but I might be able to implement this over the weekend.

@edcarroll
Copy link
Owner

Thank you for this 😄 Btw, I did some digging earlier and found this pull request, in which the demo has stuff like vertical sliders and ticks for steps - I wonder if it would be easier to incorporate the CSS from this PR? Then things should be a bit easier and not require any custom CSS from this library...

What are your thoughts?

@gotenxds
Copy link
Contributor Author

gotenxds commented Jul 20, 2017

Wow, that demo is really well done, it adds a lot of features, I'l take a stab at it at the weekend.

Now looking at that PR, it looks like the entire CSS is LESS and we cant really include it as a link without including it inside the project, how would you like to advance with this ?
We could add that less code to the project or compile it to css and push it as a different package to npm.

Copy link
Owner

@edcarroll edcarroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few initial comments. Am encountering a bug in which the thumb stays attached to the mouse after clicking off and won't go away.

I'd really like to include the functionality from the linked PR before merging this (specifically 2 thumbs, vertical & snapping to steps) - what are your thoughts there?

Thanks, and apologies for the slowness, trying to finish up a work project that is becoming a bit all encompassing!

@@ -1,12 +1,8 @@
import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";
import { GettingStartedPage } from "./pages/getting-started/getting-started.page";

// Collections
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the import structure as it was

@@ -0,0 +1,43 @@
<demo-page-title>
<div header>Rating</div>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range

<demo-page-title>
<div header>Rating</div>
<div sub-header>
<p>A rating indicates user interest in content</p>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A range allows you to select a range of values?

CSS alongside Semantic UI's.
</p>
<div class="ui segment">
<demo-codeblock language="markup" [src]="cssInclude"></demo-codeblock>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo has the code in it... I wonder if there is a way of easily pulling out the theming files?

@Component({
selector: "sui-range",
template: `
<div class="ui range" [ngClass]="{'disabled': isReadonly}" >
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use [disabled]="isReadonly"

selector: "sui-range",
template: `
<div class="ui range" [ngClass]="{'disabled': isReadonly}" >
<div #inner class="inner" (mousedown)="onDown($event, false)" (touchstart)="onDown($event, true)">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth moving some of this complexity into a thumb.ts file?

})
export class SuiRange implements OnInit {
@Input() public max:number = 100;
@Input() public min:number = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialise in constructor

export class SuiRange implements OnInit {
@Input() public max:number = 100;
@Input() public min:number = 0;
@Input() public step:number = 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, won't write this for all of them 😛

const upEventName = isTouch ? "touchend" : "mouseup";
const moveEventName = isTouch ? "touchmove" : "mousemove";

const removeOnUp = this._renderer.listen("window", upEventName, () => this.onUp());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use @HostListener()?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for efficiency?

@@ -1,12 +1,5 @@
import { NgModule } from "@angular/core";

// Collections
import {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep original structure

@edcarroll
Copy link
Owner

I've linked the fork that the PR is coming from, which has the Range CSS & overrides to allow themeing support. I'm trying to think of how best to enable extra builds (perhaps a custom module just for theming?)

@edcarroll
Copy link
Owner

I've had a chat with a few people about this and I think going down the route of having a separate module that packages the CSS is the way to go, so I'll be working on that in a few weeks. This will work excellently with this PR because it means we can include the external styles for now, but then when the builder is in place it will be automatically included for people so they don't need to worry about Range or Datepicker CSS 😄

@edcarroll
Copy link
Owner

Hey @gotenxds just wanted to check in with you see how you were getting on 😄

@gotenxds
Copy link
Contributor Author

gotenxds commented Aug 8, 2017

Hi @edcarroll sorry, I've been really swamped lately so I've had like 0 time to work on anything, I'l try and get back to this this weekend.

@edcarroll
Copy link
Owner

@gotenxds no worries at all, no rush (work is certainly more important!) - just wanted to check in 😄

@edcarroll edcarroll modified the milestone: 0.11.0 Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants