Как я могу сделать эту кнопку в React. js с помощью пользовательского интерфейса материала или другого инструмента? - PullRequest
0 голосов
/ 29 мая 2020

Я хочу сделать кнопку похожей на это изображение. Я думаю, что состоит из кнопки (левая сторона), я не знаю, как я могу сделать ее правую сторону (рисунок стрелки), а внутри стрелки - изображение и типографика, я думаю. Надеюсь, ты сможешь мне помочь !!

enter image description here

Ответы [ 2 ]

1 голос
/ 31 мая 2020

Вы можете поступить так: вы создаете компонент кнопки и форматируете его с помощью css, вы создаете кончик стрелки с помощью псевдоэлемента.

const App = () => {

  const icon1 = "https://img.icons8.com/ios-filled/50/000000/crane.png"
  const icon2 = "https://img.icons8.com/ios-glyphs/30/000000/interstate-plow-truck.png"
  
  const ArrowButton = ( props ) => (
    <div className="arrow_box" onClick={props.click} >
    <div className="arrow_button"></div>
    <div className="arrow_content">
      <div className="arrow_content_img-box">
      <img className="arrow_content_img" alt="icon" src={props.icon} />
      </div>
      <span className="arrow_content_text">{props.iconRef}</span>
    </div>
  </div>
  )

  const handleClick = () => {
    alert('click')
  }

  return (
    <div className="container">
      <h1 className="title__primary">Arrow Button</h1>
      <ArrowButton icon={icon1} iconRef={"pl001"} click={handleClick} />
      <ArrowButton icon={icon2} iconRef={"fr005"} click={handleClick} />
    </div>
  );
};

    ReactDOM.render(
      <App />, document.getElementById("react")
);
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: sans-serif;
  text-align: center;
}

.arrow_box {
  width: 200px;
  height: 60px;
  margin: 5px;
  cursor: pointer;
  border-top: 2px solid #c9cdd0;
  border-bottom: 2px solid #c9cdd0;
  border-left: 2px solid #c9cdd0;
  border-radius: 8px 0 0 8px;
  background-color: #ffffff;
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: row;
}

.arrow_box::before {
  content: "";
  position: absolute;
  width: 40px;
  height: 40px;
  top: 50%;
  left: 89.5%;
  background-color: #ffffff;
  border-top: 2px solid #c9cdd0;
  border-right: 2px solid #c9cdd0;
  transform: rotate(45deg);
  margin-top: -21px;
}

.arrow_box:hover, .arrow_box:hover::before{
  background-color: #006eff;
}

.arrow_button {
  position: relative;
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  color: #ffffff;
  background-color: #00122c;
  border-radius: 6px 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arrow_button::before {
  content: "\2716";
}

.arrow_content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  height: 56px;
  width: 144px;
}

.arrow_content_img-box {
  height: 50px;
  width: 50px;
  border-radius: 50%;
  background-color: #ffe8aa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arrow_content_img {
  height: 35px;
  width: auto;
  filter: invert(75%) sepia(32%) saturate(7078%) brightness(100%)
    hue-rotate(15deg) contrast(100%);
}

.arrow_content_text {
  text-transform: uppercase;
  font-size: 1.5rem;
  font-weight: bold;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

<div id="react"></div>
0 голосов
/ 29 мая 2020

Я бы просто разделил элемент на 3 блока: два прямоугольника и треугольник. Левый прямоугольник - кнопка со значком внутри, правый прямоугольник - изображение и текст, а треугольник - просто пустой div. Это стиль, который вы можете придать div, чтобы он выглядел как нужный вам треугольник.

triangle: {
 width: 0,
 height: 0,
 backgroundColor: "transparent",
 borderStyle: "solid",
 borderLeftWidth: 50,
 borderRightWidth: 50,
 borderBottomWidth: 100,
 borderLeftColor: "transparent",
 borderRightColor: "transparent",
 borderBottomColor: "red",
 transform: "rotate(90deg)" }

деление

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...