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

Adding ui-checkbox element. #31

Closed
wants to merge 1 commit into from

Conversation

kklane
Copy link
Contributor

@kklane kklane commented Feb 22, 2017

No description provided.

classes (cond-> (str user-classes " c-checkbox ")
(contains? legal-styles style) (str (name style))
)
attrs (cond-> attrs
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop the cond. If everything should be done, then it isn't conditional :)

Also assoc and dissoc can do more than one at a time:

(-> attrs 
    (assoc :type "checkbox" :className classes :id (name id))
    (dissoc :styles))

user-classes (get attrs :className "")
classes (cond-> (str user-classes " c-checkbox ")
(contains? legal-styles style) (str (name style))
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Style guide: no closing brace of any kind should start the non-whitespace of a line. Join this up to the line above.

)
attrs (cond-> attrs
:always (assoc :type "checkbox")
:always (dissoc :styles)
Copy link
Contributor

Choose a reason for hiding this comment

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

Type: I think you mean style...but I would not use that, since it has an HTML meaning. See above comments on API of this method.

:always (assoc :id (name id))) ]
(dom/span #js {} (dom/input (clj->js attrs))
(dom/label #js {:htmlFor id} \u00A0))
))
Copy link
Contributor

Choose a reason for hiding this comment

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

Dangling parens


className (optional): additional class stylings to apply to the top level of the checkbox
id: Name of the checkbox
style (optional): is-indeterminate :c-checkbox--informative"
Copy link
Contributor

Choose a reason for hiding this comment

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

What you want is:

:checked - Can be one of true, false, or :indeterminate

that way it is compatible with normal checkbox use (true/false), but can support the additional case.

:style should never be used in our elements, since it is an HTML predefined attribute.

You can use (identical? true v) to check that something is the actual boolean value true (or false for that matter).

(dom/div nil
(e/ui-checkbox {:id "checkbox"} )
(e/ui-checkbox {:id "checkbox" :style #{:is-indeterminate}} )
(e/ui-checkbox {:id "checkbox" :style #{:c-checkbox--informative}} )
Copy link
Contributor

Choose a reason for hiding this comment

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

API should never talk about CSS classes (you're mixing a CSS stye name into a user-visible API). It should be abstract.

id: Name of the checkbox
style (optional): is-indeterminate :c-checkbox--informative"
[{:keys [id style] :or {id ""} :as attrs}]
(let [legal-styles #{:is-indeterminate :c-checkbox--informative}
Copy link
Member

Choose a reason for hiding this comment

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

Informative has been removed as it's an internal-only class we don't need in this project.

@awkay
Copy link
Contributor

awkay commented Mar 7, 2017

Merged manually. Still needs fixes, but cannot continue waiting for requested changes.

@awkay awkay closed this Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants