Skip to content

Instantly share code, notes, and snippets.

@manabuyasuda
Last active December 14, 2021 07:10
Show Gist options
  • Select an option

  • Save manabuyasuda/2f12f3ba828fd5a4059e0ff4382a8104 to your computer and use it in GitHub Desktop.

Select an option

Save manabuyasuda/2f12f3ba828fd5a4059e0ff4382a8104 to your computer and use it in GitHub Desktop.
//- @param {Object} params
//- @param {String} params.id [""] id属性値
//- @param {String} params.name [""] name属性値
//- @param {String} params.value [""] value属性値
//- @param {boolean} params.disabled [false] disabled属性値を出力するかの真偽値
//- @param {boolean} params.error [false] エラー表示用のクラスを出力するかの真偽値
//-
//- @examples Input
//- +Checkbox({id: "checkbox1-1", name: "checkbox1", value: "0"}) チェックボックス1
//-
//- @examples Output
//- <input class="sw-FormCheckbox" type="checkbox" id="checkbox1-1" name="checkbox1" value="0" />
//- <label for="checkbox1-1">
//- <svg role="img">
//- <use xlink:href="/assets/svg/sprite.svg#checkbox1"></use>
//- </svg>
//- <span>チェックボックス1</span>
//- </label>
mixin Checkbox(params={})
-
const props = Object.assign({
id: "",
name: "",
value: "",
disabled: false,
error: false,
}, params)
input.sw-FormCheckbox(
type="checkbox"
id=props.id
name=props.name
value=props.value
disabled=props.disabled
class={"-error": props.error}
)&attributes(attributes)
label(for=props.id)
svg(role="img")
use(xlink:href="/assets/svg/sprite.svg#checkbox1")
span
block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment