Checkbox based Toggle Switch component with swipe/drag support for Ember.
Based on this codepen.Here's the official demo using this component.
ember install ember-toggle
There are many themes
which change the visual appearance of the toggle.Check the demo for interactive examples.
'default'
'ios'
'light'
'flat'
'flip'
'skewed'
'material'
Use it along with the @variant='auto'
or @variant='dark'
option to get a dark themed version, works only with 'ios', 'flat' and 'material' theme.
Example of changing the theme
Note: By default all themes are included, see the Configuration section to change which themes are included/excluded.
You can also adjust the size of the widget by use of the size
property. Valid sizes are:
'small'
'medium'
'large'
This option is available on all themes but is a less sensible choice for those themes which actuallyinclude the label within the control (e.g., skew
and flip
).
You can customize labels (The text the user sees for the two states) and their associated values:
If you want your labels to be displayed, then you must set showLabels
to true
.
value
- The state of the switch, can be true
or false
. Defaults to false
.onToggle
- The action that should change the state of value
.theme
- One of 'light', 'ios', 'flat', 'material', 'flip', 'skewed', 'default'.variant
- One of dark
or auto
. Use auto
for system dependent light/dark theme. Works only with ios
, flat
and material
theme.Defaults to 'default' if not specified.size
- One of 'small', 'medium', 'large'.Defaults to 'medium' if not specified.onLabel
- The label for the on state. Defaults to 'On'.offLabel
- The label for the off state. Defaults to 'Off'.showLabels
- Defaults to 'false', if 'true' will display labels on left and ride side of toggle switchdisabled
- Defaults to false
, which means you can click the toggle.When true
, an .x-toggle-disabled
class is set on the toggle and an .x-toggle-container-disabled
class is set on the component.name
- A name to differentiate multiple toggles, gets passed to the toggle
action. Defaults to 'default'.Add a configuration for ember-toggle
to include only the themes thatyou will use, as well as any other default settings that apply to all togglesin your app. These defaults can be overriden on a per toggle basis(except the options regarding themes being added to your app's build step).
This configuration is located in config/environment.js
.
The following is an example of how you can configure this addon:
ENV['ember-toggle'] = {
includedThemes: ['light', 'default', 'flip'],
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'
};
note: the IOS theme is referred to as just
ios
notios7
as was indicated in the originating CSS source
To exclude (not include) a theme, means that it's css styles will not be bundled withyour application, keeping your app's css bundle size smaller.
Note: including a blank array e.g.
includeThemes: []
will not include any themes, leavingyou to define your own theme styles. See thevendor/ember-toggle/themes
directoryfor reference.Note: you may also want to setexcludeBaseStyles: true
so that this addon doesn't include the stylesused by all the themes.
If you need custom labels, additional markup, or non-standard behavior, you are in the right section.
The x-toggle
component also provides a composable component API.
The above is a simple example that returns a basic toggle, but you can see howthis could be used to wrap the switch or the labels in custom markup or logic.
This format allows greater flexibility with labels, like the single label use-case.
Note: The
not
helper is a custom Ember helper in the above example.
See the Contributing guide for details.
MIT
本文从http://www.ibeginer.sinaapp.com迁移过来,欢迎访问原页面。 简单讲属性绑定其实就是在HTML标签内(是在一个标签的”<”和“>”中使用)直接使用handlebars表达式。可以直接用handlebars表达式的值作为HTML标签中某个属性的值。 准备工作:ember generate route binding-element-attributes 1,
Ember检查器是一个浏览器插件,用于调试Ember应用程序。 灰烬检查员包括以下主题 - S.No. 灰烬检查员方式和描述 1 安装Inspector 您可以安装Ember检查器来调试您的应用程序。 2 Object Inspector Ember检查器允许与Ember对象进行交互。 3 The View Tree 视图树提供应用程序的当前状态。 4 检查路由,数据选项卡和库信息 您可以看到检查
英文原文: http://emberjs.com/guides/getting-ember/index/ Ember构建 Ember的发布管理团队针对Ember和Ember Data维护了不同的发布方法。 频道 最新的Ember和Ember Data的 Release,Beta 和 Canary 构建可以在这里找到。每一个频道都提供了一个开发版、最小化版和生产版。更多关于不同频道的信息可以查看博客
ember-emojione ember-emojione is your emoji solution for Ember, based on the EmojiOne project. EmojiOne version 2 is used, which is free to use for everyone (CC BY-SA 4.0), you're only required to giv
Ember 3D Ember 3D is an Ember addon for using Three.js - an easy to use, lightweight, javascript 3D library. It is designed to: Prescribe a solid file structure to Three.js code using ES6 modules. Ena
Ember Table An addon to support large data set and a number of features around table. Ember Table canhandle over 100,000 rows without any rendering or performance issues. Ember Table 3.x supports: Emb
vscode-ember This is the VSCode extension to use the Ember Language Server. Features All features currently only work in Ember-CLI apps that use classic structure and are a rough first draft with a lo
ember-headlessui This is a work-in-progress implementation of: https://github.com/tailwindlabs/headlessui A set of completely unstyled, fully accessible UI components for Ember.js, designed to integra
Ember Popper An Ember-centric wrapper around Popper.js. Currently an alpha in active development. See the dummy app for examples Compatibility Ember.js v3.12 or above Ember CLI v2.13 or above Node.js