aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/decorators/Labelled.js
blob: 35cd58a6ec2eaf4e8e049c86acb43bf7428351ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import styled from "styled-components";
import React from "react";

const StyledLabel = styled.label`
  position: relative;
  & > div:first-child {
      position: absolute;
  }
  & > div > span {
    display: block;
    transform: translateY(-0.2em);
    font-weight: 700;
    font-size: 1em;
    opacity: 0.5;
    transition: opacity 0.5s cubic-bezier(.25,.8,.25,1);
  }
  
  &:hover > span {
    opacity: 1;
  }
`

const FloatingLabel = (props) => <StyledLabel label={props.label}>
  {props.children}
</StyledLabel>


export const Labelled = ({label, value, children}) => <FloatingLabel label={label} value={value} >
  <div>
    <span>{label}</span>
  </div>
  {children}
</FloatingLabel>