arifszn/reactive-button

View on GitHub
src/css/index.css

Summary

Maintainability
Test Coverage
.reactive-btn-wrapper,
.reactive-btn {
  --reactive-button-min-width: 100px;
  --reactive-button-min-height: 35px;
  --reactive-button-font-size: 14px;
  --reactive-button-font-weight: 400;
  --reactive-button-border-radius: 0px;
  --reactive-button-text-color: #ffffff;
  --reactive-progress-color: rgba(0, 0, 0, 0.15);

  --reactive-button-primary-color: rgba(88, 103, 221, 1);
  --reactive-button-secondary-color: rgba(108, 117, 125, 1);
  --reactive-button-dark-color: rgba(66, 78, 106, 1);
  --reactive-button-light-color: rgba(183, 186, 191, 1);
  --reactive-button-green-color: rgba(37, 162, 51, 1);
  --reactive-button-red-color: rgba(244, 81, 108, 1);
  --reactive-button-yellow-color: rgba(255, 193, 7, 1);
  --reactive-button-teal-color: rgba(0, 181, 173, 1);
  --reactive-button-violet-color: rgba(100, 53, 201, 1);
  --reactive-button-blue-color: rgba(66, 153, 225, 1);

  --reactive-progress-outline-primary-color: rgba(88, 103, 221, 0.3);
  --reactive-progress-outline-secondary-color: rgba(108, 117, 125, 0.3);
  --reactive-progress-outline-dark-color: rgba(66, 78, 106, 0.3);
  --reactive-progress-outline-light-color: rgba(214, 212, 212, 0.3);
  --reactive-progress-outline-green-color: rgba(37, 162, 51, 0.3);
  --reactive-progress-outline-red-color: rgba(244, 81, 108, 0.3);
  --reactive-progress-outline-yellow-color: rgba(255, 193, 7, 0.3);
  --reactive-progress-outline-teal-color: rgba(0, 181, 173, 0.3);
  --reactive-progress-outline-violet-color: rgba(100, 53, 201, 0.3);
  --reactive-progress-outline-blue-color: rgba(66, 153, 225, 0.3);
}

.reactive-btn-wrapper {
  display: inline-block;
  min-width: var(--reactive-button-min-width);
  height: var(--reactive-button-min-height);
}

.reactive-btn-wrapper.tiny {
  min-width: calc(var(--reactive-button-min-width) - 35px);
  height: calc(var(--reactive-button-min-height) - 11px);
}

.reactive-btn-wrapper.small {
  min-width: calc(var(--reactive-button-min-width) - 25px);
  height: calc(var(--reactive-button-min-height) - 5px);
}

.reactive-btn-wrapper.large {
  min-width: calc(var(--reactive-button-min-width) + 25px);
  height: calc(var(--reactive-button-min-height) + 5px);
}

.reactive-btn-wrapper.block {
  width: 100%;
}

.reactive-btn {
  margin-bottom: 0;
  padding: 6px 14px 6px;
  font-size: var(--reactive-button-font-size);
  font-weight: var(--reactive-button-font-weight);
  width: 100%;
  min-height: 100%;
  color: var(--reactive-button-text-color);
  text-align: center;
  line-height: 1.5;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  vertical-align: middle;
  cursor: pointer;
  background-color: var(--reactive-button-primary-color);
  border: none;
  -webkit-border-radius: var(--reactive-button-border-radius);
  -moz-border-radius: var(--reactive-button-border-radius);
  border-radius: var(--reactive-button-border-radius);
  -webkit-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
  -moz-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
  -webkit-transition: 0.1s;
  -moz-transition: 0.1s;
  transition: 0.1s;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  outline: none !important;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-box-align: center;
}

.reactive-btn.outline {
  background-color: transparent !important;
}

.reactive-btn:disabled {
  cursor: default;
}

.reactive-btn:hover:not(:disabled):not(.disabled) {
  opacity: 0.85;
}

.reactive-btn:not(.no-animation):hover:not(:disabled):not(.disabled) {
  opacity: 0.85;
  -webkit-box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
  -moz-box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
  margin-top: -1px;
  padding: 6px 14px 8px;
}

.reactive-btn:not(.no-animation):active:not(:disabled):not(.disabled) {
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
  margin-top: 1px;
  padding: 6px 14px 4px;
}

.reactive-btn:focus {
  outline: none !important;
}

.reactive-btn.rounded {
  border-radius: 50rem !important;
  -webkit-border-radius: 50rem !important;
  -moz-border-radius: 50rem !important;
}

.reactive-btn.disabled {
  opacity: 0.7;
}

.reactive-btn .content {
  position: relative;
}

.reactive-btn .progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  width: 100%;
  background-color: var(--reactive-progress-color);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.reactive-btn:not([data-button-state='idle']) .progress {
  transform: translateX(0%);
  transition: transform 3s cubic-bezier(0.59, 0.01, 0.41, 0.99);
}

.reactive-btn .drbll1:after {
  content: '.';
  animation: dots 1s steps(5, end) infinite;
}

.reactive-btn-wrapper.tiny .reactive-btn {
  font-size: calc(var(--reactive-button-font-size) - 4px);
  line-height: 1;
}

.reactive-btn-wrapper.small .reactive-btn {
  font-size: calc(var(--reactive-button-font-size) - 2px);
}

.reactive-btn-wrapper.large .reactive-btn {
  font-size: calc(var(--reactive-button-font-size) + 2px);
}

/* primary button starts */
.reactive-btn.primary.outline {
  border-color: var(--reactive-button-primary-color);
  color: var(--reactive-button-primary-color);
  border: 1px solid var(--reactive-button-primary-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-primary-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-primary-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-primary-color);
}

.reactive-btn.primary.outline .progress {
  background-color: var(--reactive-progress-outline-primary-color) !important;
}

.reactive-btn.primary.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-primary-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-primary-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-primary-color);
}

.reactive-btn.primary.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-primary-color) !important;
}

/* primary button ends */

/* secondary button starts */
.reactive-btn.secondary {
  background: var(--reactive-button-secondary-color);
}

.reactive-btn.secondary.outline {
  border-color: var(--reactive-button-secondary-color);
  color: var(--reactive-button-secondary-color);
  border: 1px solid var(--reactive-button-secondary-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-secondary-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-secondary-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-secondary-color);
}

.reactive-btn.secondary.outline .progress {
  background-color: var(--reactive-progress-outline-secondary-color) !important;
}

.reactive-btn.secondary.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-secondary-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-secondary-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-secondary-color);
}

.reactive-btn.secondary.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-secondary-color) !important;
}

/* secondary button ends */

/* dark button starts */

.reactive-btn.dark {
  background: var(--reactive-button-dark-color);
}

.reactive-btn.dark.outline {
  border-color: var(--reactive-button-dark-color);
  color: var(--reactive-button-dark-color);
  border: 1px solid var(--reactive-button-dark-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-dark-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-dark-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-dark-color);
}

.reactive-btn.dark.outline .progress {
  background-color: var(--reactive-progress-outline-dark-color) !important;
}

.reactive-btn.dark.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-dark-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-dark-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-dark-color);
}

.reactive-btn.dark.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-dark-color) !important;
}

/* dark button ends */

/* light button starts */

.reactive-btn.light {
  background: var(--reactive-button-light-color);
  color: #000000;
}

.reactive-btn.light.outline {
  border-color: var(--reactive-button-light-color);
  color: var(--reactive-button-light-color);
  border: 1px solid var(--reactive-button-light-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-light-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-light-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-light-color);
}

.reactive-btn.light.outline .progress {
  background-color: var(--reactive-progress-outline-light-color) !important;
}

.reactive-btn.light.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-light-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-light-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-light-color);
}

.reactive-btn.light.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-light-color) !important;
}

/* light button ends */

/* green button starts */
.reactive-btn.green {
  background: var(--reactive-button-green-color);
}

.reactive-btn.green.outline {
  border-color: var(--reactive-button-green-color);
  color: var(--reactive-button-green-color);
  border: 1px solid var(--reactive-button-green-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-green-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-green-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-green-color);
}

.reactive-btn.green.outline .progress {
  background-color: var(--reactive-progress-outline-green-color) !important;
}

.reactive-btn.green.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-green-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-green-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-green-color);
}

.reactive-btn.green.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-green-color) !important;
}

/* green button ends */

/* red button starts */
.reactive-btn.red {
  background: var(--reactive-button-red-color);
}

.reactive-btn.red.outline {
  border-color: var(--reactive-button-red-color);
  color: var(--reactive-button-red-color);
  border: 1px solid var(--reactive-button-red-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-red-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-red-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-red-color);
}

.reactive-btn.red.outline .progress {
  background-color: var(--reactive-progress-outline-red-color) !important;
}

.reactive-btn.red.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-red-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-red-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-red-color);
}

.reactive-btn.red.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-red-color) !important;
}

/* red button ends */

/* yellow button starts */
.reactive-btn.yellow {
  background: var(--reactive-button-yellow-color);
  color: #000000;
}

.reactive-btn.yellow.outline {
  border-color: var(--reactive-button-yellow-color);
  color: var(--reactive-button-yellow-color);
  border: 1px solid var(--reactive-button-yellow-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-yellow-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-yellow-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-yellow-color);
}

.reactive-btn.yellow.outline .progress {
  background-color: var(--reactive-progress-outline-yellow-color) !important;
}

.reactive-btn.yellow.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-yellow-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-yellow-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-yellow-color);
}

.reactive-btn.yellow.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-yellow-color) !important;
}

/* yellow button ends */

/* teal button starts */
.reactive-btn.teal {
  background: var(--reactive-button-teal-color);
}

.reactive-btn.teal.outline {
  border-color: var(--reactive-button-teal-color);
  color: var(--reactive-button-teal-color);
  border: 1px solid var(--reactive-button-teal-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-teal-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-teal-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-teal-color);
}

.reactive-btn.teal.outline .progress {
  background-color: var(--reactive-progress-outline-teal-color) !important;
}

.reactive-btn.teal.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-teal-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-teal-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-teal-color);
}

.reactive-btn.teal.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-teal-color) !important;
}

/* teal button ends */

/* violet button starts */
.reactive-btn.violet {
  background: var(--reactive-button-violet-color);
}

.reactive-btn.violet.outline {
  border-color: var(--reactive-button-violet-color);
  color: var(--reactive-button-violet-color);
  border: 1px solid var(--reactive-button-violet-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-violet-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-violet-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-violet-color);
}

.reactive-btn.violet.outline .progress {
  background-color: var(--reactive-progress-outline-violet-color) !important;
}

.reactive-btn.violet.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-violet-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-violet-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-violet-color);
}

.reactive-btn.violet.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-violet-color) !important;
}

/* violet button ends */

/* blue button starts */
.reactive-btn.blue {
  background: var(--reactive-button-blue-color);
}

.reactive-btn.blue.outline {
  border-color: var(--reactive-button-blue-color);
  color: var(--reactive-button-blue-color);
  border: 1px solid var(--reactive-button-blue-color);
  box-shadow: inset 0 -1px 0 var(--reactive-button-blue-color);
  -webkit-box-shadow: inset 0 -1px 0 var(--reactive-button-blue-color);
  -moz-box-shadow: inset 0 -1px 0 var(--reactive-button-blue-color);
}

.reactive-btn.blue.outline .progress {
  background-color: var(--reactive-progress-outline-blue-color) !important;
}

.reactive-btn.blue.outline:hover:not(:disabled):not(.disabled) {
  box-shadow: inset 0 -3px 0 var(--reactive-button-blue-color);
  -webkit-box-shadow: inset 0 -3px 0 var(--reactive-button-blue-color);
  -moz-box-shadow: inset 0 -3px 0 var(--reactive-button-blue-color);
}

.reactive-btn.blue.shadow {
  box-shadow: 0px 5px 16px -3px var(--reactive-button-blue-color) !important;
}

/* blue button ends */

.reactive-spin {
  animation: reactive-spin 2s infinite linear;
}
.reactive-btn-loading-svg,
.reactive-btn-success-svg,
.reactive-btn-error-svg {
  display: inline-block;
  font-size: inherit;
  height: 1em;
  overflow: visible;
  vertical-align: -0.125em;
}

@keyframes dots {
  0%,
  20% {
    color: rgba(0, 0, 0, 0);
    text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0);
  }

  40% {
    color: white;
    text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0);
  }

  60% {
    text-shadow: 0.25em 0 0 white, 0.5em 0 0 rgba(0, 0, 0, 0);
  }

  80%,
  100% {
    text-shadow: 0.25em 0 0 white, 0.5em 0 0 white;
  }
}

@keyframes reactive-spin {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}