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

create a scss mixin #25

Open
macolo opened this issue Mar 7, 2020 · 0 comments
Open

create a scss mixin #25

macolo opened this issue Mar 7, 2020 · 0 comments

Comments

@macolo
Copy link

macolo commented Mar 7, 2020

The following has been tested for normal input fields of type text in most recent Safari, Firefox, Chrome on mac os x.

Here is a sample html markup, it includes some vue markup as well, but this can be removed without any side effects:

<div class="row">
                    <div class="col-24 col-md-18">
                        <keep-alive>
                            <ValidationProvider name="street" rules="required" v-slot="{ errors }">
                                <div class="form-group">
                                    <label class="has-float-label">
                                        <input class="form-control" name="street" type="text" placeholder="Street"
                                               :class="{ 'is-invalid': errors[0] }"
                                               v-model="formData.street">
                                        <span>Street</span>
                                    </label>
                                    <p class="invalid-feedback d-block">
                                        {{ errors[0] }}
                                    </p>
                                </div>
                            </ValidationProvider>
                        </keep-alive>
                    </div>
</div>

Could this be added to the sources somehow? A mixin can come pretty handy for those that use bootstrap-sass anyway.

@import "~bootstrap/scss/functions/";
@import "~bootstrap/scss/mixins/";
@import "~bootstrap/scss/variables/";

@mixin has-float-label {
  // taken from https://github.com/tonystar/bootstrap-float-label/blob/master/bootstrap-float-label.css
  display: block;
  position: relative;

  label, & > span {
    background: white;
    position: absolute;
    cursor: text;
    font-size: 75%;
    opacity: 1;
    -webkit-transition: all .2s;
    transition: all .2s;
    top: -.5em;
    left: 0.75rem;
    z-index: 3;
    line-height: 1;
    padding: 0 2px;
  }

  .form-control {

    &::placeholder {
      opacity: 1;
      transition: all .2s;
    }

    &:placeholder-shown:not(:focus)::placeholder {
      opacity: 0;
    }

    &:placeholder-shown:not(:focus) + * {
      font-size: 100%;
      color: $input-placeholder-color;
      transform: translateY(-50%);
      top: 50%;
    }
  }

}

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

1 participant