Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 849 | Rev 1161 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React from 'react'
import styled from 'styled-components'
import { device } from '../../styles/MediaQueries'
import { Avatar } from '@mui/material'
import { Link } from 'react-router-dom'

const LayoutContainer = styled.div`
  background-color: var(--bg-color);
  box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.08);
  height: fit-content;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  span {
    font-size: 0.9rem;
  }
  p {
    color: var(--font-color);
    font-size: 14px;
    text-align: justify;
    margin-bottom: 0.5rem;
  }
  h2 {
    font-size: 1rem;
  }
  @media ${device.tablet} {
    border-radius: var(--border-radius);
  }
`

const LayoutHeader = styled.div`
  display: flex;
  gap: 0.5rem;
  padding: 10px 1rem;
  align-items: center;
  justify-content: space-between;
  position: relative;
`

const LayoutBody = styled.div`
  padding: 10px 1rem;
  display: flex;
  flex-direction: column;
`

const HeaderInfo = styled.div`
  align-items: center;
  display: inline-flex;
  gap: 0.5rem;
  width: fit-content;
`

const HeaderContent = styled.div`
  display: flex;
  flex-direction: column;
`

const LayoutActions = styled.div`
  display: flex;
  justify-content: space-around;
  border-top: 1px solid rgb(211, 211, 211);
  padding: 5px;
  gap: 0.5rem;
  & > button,
  & > a {
    align-items: center;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    font-size: 0.9rem;
    padding: 5px;
    position: relative;
    &:hover {
      background-color: whitesmoke;
    }
    @media ${device.tablet} {
      flex-direction: row;
      gap: 0.5rem;
      font-size: 1rem;
    }
  }
`

const StyledContainer = ({ children, ...rest }) => {
  return <LayoutContainer {...rest}>{children}</LayoutContainer>
}

const Actions = ({ children, ...rest }) => {
  return <LayoutActions {...rest}>{children}</LayoutActions>
}

const Body = ({ children, ...rest }) => {
  return <LayoutBody {...rest}>{children}</LayoutBody>
}

const Header = ({
  image = '',
  title = '',
  url = '',
  timeElapsed = '',
  children,
  ...rest
}) => {
  return (
    <LayoutHeader {...rest}>
      <HeaderInfo>
        {image && (
          <Avatar
            src={image}
            alt={`${title} profile image`}
            sx={{ width: '50px', height: '50px' }}
          />
        )}
        <HeaderContent>
          {url ? (
            <Link to={url}>
              <h2>{title}</h2>
            </Link>
          ) : (
            <h2>{title}</h2>
          )}
          {timeElapsed && <span>{timeElapsed}</span>}
        </HeaderContent>
      </HeaderInfo>
      {children}
    </LayoutHeader>
  )
}

StyledContainer.Actions = Actions
StyledContainer.Header = Header
StyledContainer.Body = Body

export default StyledContainer