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

_forms.scss improvements (for radio and checkbox) #260

Closed
ghost opened this issue Jan 12, 2017 · 2 comments
Closed

_forms.scss improvements (for radio and checkbox) #260

ghost opened this issue Jan 12, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 12, 2017

This change will likely need to be delayed until the next major release as it changes some default behavior.

Goals:

  1. support syntax
  2. support inline inputs

Sample HTML

<form action="action_page.php">
  <div grid="ng">
    <div column="6">
      <label>Gender: input label</label>
      <input id="male" type="radio" name="gender" value="Male"><label for="male">Male</label>
      <input id="female" type="radio" name="gender" value="Female"><label for="female">Female</label>
    </div>
    <div column="6">
      <label>Gender: label input</label>
      <label><input type="radio" name="gender2" value="male" checked>Male</label>
      <label><input type="radio" name="gender2" value="female">Female</label>
    </div>
  </div>
  <div grid="ng">
    <div column="6" class="_inline">
      <h5>Inline: Gender: input label</h5>
      <input id="male2" type="radio" name="gender3" value="Male"><label for="male2">Male</label>
      <input id="female2" type="radio" name="gender3" value="Female"><label for="female2">Female</label>
    </div>
    <div column="6" class="_inline">
      <h5>Inline: label input</h5>
      <label><input type="radio" name="gender4" value="male" checked>Male</label>
      <label><input type="radio" name="gender4" value="female">Female</label>
    </div>
  </div>

  <div grid="no-gutter">
    <div column="6">
    <h5>input label</h5>
    <input id="bike" type="checkbox" name="vehicle1" value="Bike"><label for="bike">I have a bike</label>
    <input id="car" type="checkbox" name="vehicle2" value="Car"><label for="car">I have a car</label>
    </div>
    <div column="6">
    <h5>label input</h5>
    <label><input type="checkbox" name="transport1" value="Bike" checked>I have a bike</label>
    <label><input type="checkbox" name="transport2" value="Car">I have a car</label>
    </div>
  </div>

  <div grid="ng">
    <div column="6" class="_inline">
    <h5>Inline: input label</h5>
    <input id="bike2" type="checkbox" name="vehicle3" value="Bike"><label for="bike2">I have a bike</label>
    <input id="car2" type="checkbox" name="vehicle4" value="Car"><label for="car2">I have a car</label>
    </div>
    <div column="6" class="_inline">
    <h5>Inline: label input</h5>
    <label><input type="checkbox" name="transport3" value="Bike" checked>I have a bike</label>
    <label><input type="checkbox" name="transport4" value="Car">I have a car</label>
    </div>
  </div>
  
  <input type="submit" value="Submit">
  <button> y submit?</button>
</form> 

Changes made

concise.css/src/_forms.scss

Line 11
--   min-height: 1.5lh;
++   //min-height: 1.5lh;

Line 43
++   margin-bottom: 0.1lh;

Line 75
--   display: block;

Line 80
-- // Labels are inline with their checkbox and radio elements
++ // Inputs before label.

Line 83
--   display: inline-block;

Added to the end of the file...

++  // Inputs inside label.
++  label > input[type="radio"],
++  label > input[type="checkbox"] {
++    margin-right: 0.5em;
++  }
++  
++  // If not inline, then add a line break
++  :not(._inline) > label:after {
++    content: "\A";
++    white-space: pre;
++  }
++  
++  div._inline > label {
++    margin-right:1.5em;
++  }

chrome
firefox
ie11
safari

Modified File

concise.css/src/_forms.scss

//
// Forms
// =============================================================================

input:not([type="submit"]),
select,
textarea {
  transition-duration: $transition-duration;
  width: 100%;
  font-size: typeScale(1);
  // min-height: 1.5lh;

  &:focus {
    border-color: getColor(blue, lighter);
  }

  &[disabled] {
    background-color: getColor(state, muted);
    cursor: not-allowed;
    border: 0;
  }
}

input:not([type="submit"]):not([type="range"]),
select,
textarea {
  border: 1px solid getColor(base, lines);
  padding: 0 0.75em;
}

input[type="checkbox"],
input[type="file"],
input[type="image"],
input[type="radio"] {
  height: auto;
  width: auto;
}

input[type="checkbox"],
input[type="radio"] {
  line-height: normal;
  padding: 0;
  vertical-align: middle;
  margin-bottom: 0.1lh;
}

input[type="file"] {
  border: none;
  line-height: 1lh;
  padding: 0;
}

select {
  background-color: transparent;
  padding-left: 0.5em;
  width: auto;
  min-width: 10em;
  height: 1.5lh;

  &[disabled] { color: getColor(text, secondary); }

  &[multiple] {
    height: auto;
    width: 100%;
    padding: 0;
  }

  &::-ms-expand { display: none; }

  &::-ms-value { color: currentColor; }

  option { padding: 0 0.75em }
}

label {
  font-size: typeScale(1);
  line-height: 1.5lh;
}

// Inputs before label.
input[type="checkbox"] + label,
input[type="radio"] + label {
  margin-left: 0.5em;
}

// Inputs inside label.
label > input[type="radio"],
label > input[type="checkbox"] {
  margin-right: 0.5em;
}

// If not inline, then add a line break
:not(._inline) > label:after {
  content: "\A";
  white-space: pre;
}

div._inline > label {
  margin-right:1.5em;
}
@ghost ghost added the ver:Future label Jan 12, 2017
@ghost
Copy link

ghost commented Jan 12, 2017

Awesome, I'll check this more in deep once I get some time. Thank you!

@ghost ghost self-assigned this Jan 14, 2017
ghost pushed a commit that referenced this issue Feb 4, 2017
@ghost ghost closed this as completed Feb 4, 2017
@ghost
Copy link

ghost commented Feb 4, 2017

Done. Changes are on the development branch.

This issue was closed.
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

No branches or pull requests

0 participants