Giter Club home page Giter Club logo

ember-toggle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ember-toggle's Issues

Add sizes

  • small
  • medium
  • large

default: medium

And use a .x-toggle.small pattern for classes.

Figure out a way to only serve partial css

So only the themes that the user wants.

Ideas @rwjblue? Is it possible to configure in the Brocfile, and only import what's set, e.g.

var toggle = Toggle({
  includedThemes: ['light', 'default'],
  defaultTheme: 'light'
})

Disabled class should be set on container

Thanks for the great addon!

If you add 'on' and 'off' text to a toggle and set the toggle to disabled there is not way to style the text without reopening the x-toggle component. This is because the .x-toggle-disabled class is set on the toggle not the container.

I'd expect a class on the container like .x-toggle-container-disabled.

Collides with Ember's built-in `on` and `off` methods

Ember.Component has methods named on and off, which x-toggle is attempting to reuse for its own purposes. This fails in confusing ways on some versions of Ember. For example, using Ember 1.13 with x-toggle 0.5.10, the defaults provided in x-toggle are ignored and you end up trying to do indexOf on function values.

Unclear usage / Docs

All of the the documentation uses the mut helper, so it's unclear that value should be a string that matches the labels.
I thought value was supposed to be a boolean because of
the default value: false.

To add to that, I'm using labels that are one letter representation of the actual value they are toggling, and right now this behavior is pushed onto the consumer.

@knownasilya
Could you think of any way of supporting this so we can make it behave like a options in a select (where the label and values are different but map to each other)

Yield in template.hbs

Would be nice to have a {{yield}} at line 6 on template.hbs so that we can add our own question labels like:

{{#x-toggle value=showHidden onToggle=(mut showHidden)}}
Show hidden?
{{/x-toggle}}

Any thoughts?

Release 5.0

  • Document new APIs
  • Add toggleLabel label component, which handles the value and label display for you
  • Update to babel 6
  • Release

Theme css files not being pulled in

I have just started using ember-cli-toggle and I'm finding the css theme files are not getting compiled. If I copy and paste those files into base.css it works.

README example causes ember error

Trying to create a simple controller with a boolean flag attribute, and the code:

{{x-toggle value=flag onToggle=(mut flag)}}

As taken from the README, Ember raises an error:

Assertion Failed: You modified flag twice on <webapp@controller:session/index::ember903> in a single render. This was unreliable and slow in Ember 1.x and is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.

Tested with latest ember-cli-toggle (v2.0.2) and Ember 2.10

Changes value on insert..

I have this in my template:

{{x-toggle value=item.enabled class="pull-right"}}

Which is bound to this:

{id: 1, enabled: true}

But when the page is rendered the value of item is set to false

A helper named 'x-toggle' could not be found

I can't use the component as it seems to make the page fail with A helper named 'x-toggle' could not be found.

I can add a stack trace if needed. I ran rm -rf node_modules bower_components, then re-ran npm install && bower install.

I'm on Ember 1.13.5, EmberData 1.13.5.

Uncaught Error: Assertion Failed: A helper named 'x-toggle' could not be found

I not sure why I am getting this error in a my application. Is it because I haven't added the line below to a config file. I am new to Ember and am not sure where I'd add that information. Do I add it to environment.js or create a new file in the config folder? I am currently using Ember 2.5.1

Add a configuration for ember-cli-toggle to include only the themes that you will use.

ENV['ember-cli-toggle'] = {
includedThemes: ['light', 'default', 'flip'],
excludedThemes: ['flip'],
defaultShowLabels: true, // defaults to false
defaultTheme: 'light', // defaults to 'default'
defaultSize: 'small', // defaults to 'medium'
defaultOffLabel: 'False', // defaults to 'Off'
defaultOnLabel: 'True' // defaults to 'On'
};

Styles not available when used in an addon

Hi! When I include ember-cli-toggle into the main app, it's fine.

But when I instead include it into an addon's dependencies, the x-toggle component appear unstyled.

PS Thank you for the awesome component!

Conditional styles importing

Looks like there are some cases when you want a customized toggle and don't need those default styles. Is it suitable to make them importable optionally like add @import 'ember-cli-toggle' to the app.css?

Issue setting controller value

The value on my controller isn't being toggled or bound when changing the switch.

the code I think should work according to the README is {{x-toggle toggle='onlineOnly' theme='flip' off='All' on='Online'}}, but the value is not being updated on my controller. Going through the demo and other issues, I've seen other ways such as toggled=onlineOnly, value=onlineOnly, but none of these seem to be changing the value on my controller. Also have tried variations with to property set as controller.onlineOnly.

On my controller I have either defined the property as onlineOnly: null, or I have left off the property.

I'm new to ember and as there aren't other issues around this fundamental problem, I'm guessing I'm doing something wrong, but everything seems right to me according to the available docs.

Uncaught TypeError: Cannot read property 'defaultTheme' of undefined

Thanks for making this! Having trouble getting it to work in canary and ecli 0.2.0 stock new app

installed with npm install --save-dev ember-cli-toggle

All suggested inputs provided the subject error
{{x-toggle toggle='startCar'}}
{{x-toggle theme='light' toggle='enableLayer'}}
{{x-toggle theme='ios' size='small' toggle='muteVolume'}}
{{x-toggle theme='flat' toggle='disableTest'}}
{{x-toggle theme='flip' off='Nope' on='Yep' toggle='haveFun'}}
{{x-toggle theme='skewed' size='large' toggle='enablePartyMode'}}

Pod structure makes x-toggle undiscoverable for some apps

If an app customizes podModulePrefix, their resolver won't find app/components/x-toggle/component.js.

I think the only way for addons to remain 100% compatible is to stick with the stock structure (app/components/x-toggle.js).

the value only supports the string "True", not the boolean true

Hi! I'm doing something like this:

{{x-toggle value=tfa onToggle=(mut tfa)}}

When tfa is boolean true, the toggle is in the off state, but when tfa is the string "True", it is in the on state. If tfa is any other string, it is also off. Is this intentional, or is this a bug?

Could not find module `ember-cli-toggle/components/x-toggle/template`

Uncaught Error: Could not find module ember-cli-toggle/components/x-toggle/template imported from ember-cli-toggle/components/x-toggle/component

the above error occurs whenever i try to use {{x-toggle}} component in my application

i tried all of the below:
{{x-toggle toggle='startCar'}}
{{x-toggle theme='light' toggle='enableLayer'}}
{{x-toggle theme='ios' size='small' toggle='muteVolume'}}
{{x-toggle theme='flat' toggle='disableTest'}}
{{x-toggle theme='flip' off='Nope' on='Yep' toggle='haveFun'}}
{{x-toggle theme='skewed' size='large' toggle='enablePartyMode'}}

My ember version is 1.11.1
and Ember Data : 1.0.0-beta.16.1

CSS of toggle-component not changing

I'm rendering my component with an if like so. The boolean changes via a button.

{{#if myBoolean}} {{my-emberclitoggle-comp}} {{/if}}

And the CSS of the component is not switching to the selected state when clicked, but the value is being changed correctly.

When the component is rendered normally example:
{{my-emberclitoggle-comp}}
the CSS changes fine when clicked.

I also tried by rendering the component via transitionTo and the CSS doesn't change either.

Here is a reproduction in a vanilla 2.3.0 Ember app.
https://github.com/MarioDiar/emberToggle-Bug

Write tests

  • Run tests against other versions of ember
  • Test component
    • checking
    • disabling
    • actions

Do not trigger the toggle action at initialization

The component triggers the toggle action at initialization.
I think that isn't a good idea because at this time the position isn't defined by user.

If I want to persist my model directly when the toggle action is triggered, I should test if value is different with previous to know if it's well the user who has triggered it.

Issue with toggle width & labels

So I just installed this addon, looks pretty swish, great job!

However, the following code results in a toggle that looks like the screenshot below it;

{{x-toggle value=isLive onToggle=(action (mut isLive)) size='large' showLabels=true onLabel='Live' offLabel='History' theme='default'}}

You can see that the "Live" label is aligned next to the end of the toggle, rather than after the entire toggle container.
temp2

Here's an ember-twiddle showing the issue
https://ember-twiddle.com/306112700222db6884344a56a24cccd3?openFiles=templates.application.hbs%2C


I was able to solve this by adding width:auto to x-toggle-container (this overrides the element's set value of width:4.4rem; )

Have I done something wrong? Any idea why I had to specifically declare width:auto to get this to work?

Occurs in both Edge and Chrome

Thanks!

Blank with IOS7 and Flat

Love the underlying choice of toggle buttons but unfortunately it isn't working for me in Ember with the ios7 or flat themes. My configuration in the CLI's environment file is as follows:

var ENV = 
  // other config
  // ...
  'ember-cli-toggle': {
    includedThemes: ['light', 'default', 'flat', 'ios7'],
    excludedThemes: ['flip'],
    defaultTheme: 'flat',  
    defaultSize: 'medium',   
    defaultOff: 'False',    // defaults to 'Off'
    defaultOn: 'True'       // defaults to 'On'
  }

};

This results in no Javascript errors and the view code is rendered but it displays nothing. It appears that the light and default themes do work though.

Toggle is executing on render

  Ember      : 2.4.5
  Ember Data : 2.5.1
  jQuery     : 2.2.3

In my form component:

  {{x-toggle theme='flip' size='small' 
                  toggle='setEventStatus' 
                  value=model.isClosed
                  name='eventStatus' onLabel='Open' offLabel='Closed'}}

I find that the toggle event is firing as the route is rendered. It should not fire until a user clicks on the x-toggle component.

Demo

Hi team,

Please provide a demo link so that we can find out the proper stylesheet.

Clarify/fix discrete values

http://knownasilya.github.io/ember-toggle/

In the demo app, there is an example showing "Discrete labels and values".

{{x-toggle
  showLabels="true"
  offLabel="Hey:hey"
  onLabel="Ho:ho"
}}

The syntax for the label text looks a lot like how classNameBindings are done for components.

classNameBindings: ['isEnabled:enabled:disabled'],

So my assumption is that "Hey" would be the text, and "hey" the value, but that does not seem to be how the toggle is actually working.

It seems like the entire string is being set as both the value and the label.
screen shot 2017-05-30 at 9 33 17 am

Maybe I'm misunderstanding the intention, but what's the difference between "Hey:hey" in this example vs "Hey" in the example above?
gif

Support handling label for

Able to set id on the checkbox input, which can also be used with the label:

<label for="{{enableDeployId}}">Enable Deploy</label>
{{x-toggle for-id=enableDeployId on-toggle='enableDeploy'}}

Documentation-functionality conflict

The documentation says that adding off and on to a toggle should not change the value of a bound property unless you 'overload' the label/value:

Finally, it is sometimes the case that rather than a true or false value the toggle is meant to move between two discrete, but non-boolean states. In order to support this functionality there is an overloaded form of setting the on and off properties which not only sets a "label" for the state but also a "value". In our "hey" versus "ho" example you might do the following:

Thus, it is expected that controller.toggled is a boolean value equal to true or false in the following situation:

{{x-toggle value=controller.toggled showLabel='true' off='Hey' on='Ho'}}

However, in v0.1.15 of ember-cli-toggle, controller.toggled is always equal to Ho or Hey when it should be equal to true or false, respectively.

Allow dragging toggle

Some people try to use the toggles by dragging, but the action fails since we don't support that.

How to work with booleans?

I'm having difficulties getting this to work with toggling booleans.

component:

...
booleanValue: false,
...

template:

my value: {{booleanValue}}
{{x-toggle value=booleanValue onToggle=(mut booleanValue) theme='light' size='large'}}

.. then the output is either my value: on or my value: off. Is it possible to simply toggle between true and false?

Base toggle not using boolean values

I would have assumed unless you used the on or off computed properties that the value of the control would be a boolean true/false but instead I'm getting the capitalized text "True" and "False" for the bound value.

Theme goes blank

Hi, whenever I use the theme attribute the 'toggle-element' becomes completely blank (as in invisible).
Without defining that attribute the default 'toggle-element' comes up just fine.
(I'm using bootstrap, also without bootstrap the sam occurs)

$ ember -v
version: 1.13.8
node: 0.12.2
npm: 2.13.4
os: darwin x64

Doesn't work in 2.10

It simply doesnt work in 2.10. I tried to set up a minimal toggle button in a new project but nothing happens to the button when i click. It does not toggle.

Styling: inline switch

By default the whole switch is filling my whole table cell and its centered. How would I make it inline and align to the left? The default styling seems kind of strange to me.

s

prevent event bubbling

I tried using this inside a link-to. But when i click the switch the link-to event is sent and the switch event is cancelled.

ember-toggle not work && dont show

Hello, I have a question to ask you. I added the configuration as you requested, ember, install, ember-toggle, and config/environment, but it didn't work. Please help, thank you.

{{x-toggle value=toggled theme='ios' onToggle=(action (bsSwitchChanged toggled))}}

if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
ENV.APP.LOG_ACTIVE_GENERATION = true;
ENV.APP.LOG_TRANSITIONS = true;
ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
ENV.APP.LOG_VIEW_LOOKUPS = true;
ENV.locationType = 'hash';
ENV['ember-cli-toggle'] = {
includedThemes: ['light', 'default', 'flip','ios'],
excludedThemes: ['flip'],
excludeBaseStyles: false, // defaults to false
defaultShowLabels: true, // defaults to false
defaultTheme: 'light', // defaults to 'default'
defaultSize: 'small', // defaults to 'medium'
defaultOffLabel: 'False', // defaults to 'Off'
defaultOnLabel: 'True' // defaults to 'On'
}
}
`

image

It's my code. I don't know what's wrong with it. Please give me your advice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.