Skip to content

💡 Proposal - Progress/Loading state button #1621

@imshuffling

Description

Forma 36 contribution proposal

Currently working on a custom app, where it has a button to create a new piece of content onClick.

When the onClick happens its field input data from microservices and other locations.

During this time I wanted to have a loading/progress state So I thought i would modify an

Screen.Recording.2021-12-10.at.09.19.05.mov

Some example code... I'm setting the progress bar with in state being bumped along inside an async function call (There's probably a better way to do this) :)

<div className="btn-container">
  <button className="btn-wrapper" onClick={createBrochure}>
    <div className="btn">
      Creating <Spinner color="white" />
    </div>
    <div className="progress" style={{ width: loadingBtn }}></div>
  </button>
</div>
.btn-container {
  position: relative;
  width: 148px;
}

.btn-wrapper {
  background-color: #036fe3;
  background-size: 100% 200%;
  border: .0625rem solid #036fe3;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(25,37,50,.1);
  box-sizing: border-box;
  display: inline-block;
  font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
  font-size: .875rem;
  font-weight: 500;
  height: 2.5rem;
  overflow: hidden;
  padding: 0;
  text-decoration: none;
  transition: background .1s ease-in-out,opacity .2s ease-in-out,border-color .2s ease-in-out;
  vertical-align: middle;
  color: white;
  width: 100%;
  cursor: pointer;
}

.btn-wrapper .btn {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  line-height: 39px;
  text-align: center;
  z-index: 10;
  opacity: 1;
}

.btn-wrapper .progress {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  z-index: 5;
  background: #0059C8;
  border-radius: 6px;
  transition: width 2s ease-in-out;
}

Metadata

Metadata

Labels

needs reviewProposal/bug that needs to be reviewed by maintainersproposalstaleUsed to mark when there was no activity for a set period of time

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions