Merge branch 'master' of ssh://85.143.175.152:222/bro-js/journal.pl

This commit is contained in:
Primakov Alexandr Alexandrovich
2025-03-24 00:01:26 +03:00
42 changed files with 4264 additions and 934 deletions

View File

@@ -1,26 +1,96 @@
import styled from '@emotion/styled'
import { css, keyframes } from '@emotion/react'
export const Avatar = styled.img`
width: 96px;
height: 96px;
margin: 0 auto;
border-radius: 6px;
// Правильное определение анимации с помощью keyframes
const fadeIn = keyframes`
from {
opacity: 0;
}
to {
opacity: 1;
}
`
const pulse = keyframes`
0% {
box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.4);
}
70% {
box-shadow: 0 0 0 10px rgba(72, 187, 120, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
}
`
export const Avatar = styled.img`
width: 100%;
height: 100%;
border-radius: 12px;
object-fit: cover;
transition: transform 0.3s ease;
`
export const NameOverlay = styled.div`
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 8px;
background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
color: white;
border-bottom-left-radius: 12px;
border-bottom-right-radius: 12px;
font-size: 14px;
font-weight: 500;
text-align: center;
opacity: 0.9;
transition: opacity 0.3s ease;
.chakra-ui-dark & {
background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
}
`
// Стили без интерполяций компонентов
export const Wrapper = styled.div<{ warn?: boolean; width?: string | number }>`
list-style: none;
background-color: var(--chakra-colors-white);
padding: 16px;
border-radius: 12px;
box-shadow: 2px 2px 6px var(--chakra-colors-blackAlpha-400);
transition: all 0.5;
position: relative;
width: 180px;
min-height: 190px;
max-height: 200px;
margin-right: 12px;
padding-bottom: 22px;
border-radius: 12px;
width: 100%;
aspect-ratio: 1;
overflow: hidden;
cursor: pointer;
animation: ${fadeIn} 0.5s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
&:hover {
transform: translateY(-5px);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}
&:hover img {
transform: scale(1.05);
}
&:hover > div:last-of-type:not(button) {
opacity: 1;
}
&.recent {
animation: ${pulse} 1.5s infinite;
border: 2px solid var(--chakra-colors-green-400);
}
.chakra-ui-dark & {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
&.recent {
border: 2px solid var(--chakra-colors-green-300);
}
}
${({ width }) =>
width
? css`
@@ -31,35 +101,36 @@ export const Wrapper = styled.div<{ warn?: boolean; width?: string | number }>`
${(props) =>
props.warn
? css`
background-color: var(--chakra-colors-blackAlpha-800);
opacity: 0.7;
color: var(--chakra-colors-gray-200);
filter: grayscale(0.8);
`
: ''}
.chakra-ui-dark & {
background-color: var(--chakra-colors-gray-700);
color: var(--chakra-colors-white);
box-shadow: 2px 2px 6px var(--chakra-colors-blackAlpha-600);
}
.chakra-ui-dark &.warn {
background-color: var(--chakra-colors-blackAlpha-900);
color: var(--chakra-colors-gray-300);
}
`
export const AddMissedButton = styled.button`
position: absolute;
bottom: 8px;
right: 12px;
right: 8px;
border: none;
background-color: transparent;
opacity: 0.2;
color: inherit;
background-color: var(--chakra-colors-blue-500);
color: white;
width: 26px;
height: 26px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
opacity: 0.8;
transition: opacity 0.3s ease, transform 0.3s ease;
:hover {
&:hover {
cursor: pointer;
opacity: 1;
transform: scale(1.1);
}
.chakra-ui-dark & {
background-color: var(--chakra-colors-blue-400);
}
`

View File

@@ -1,11 +1,12 @@
import React from 'react'
import { sha256 } from 'js-sha256'
import { useColorMode } from '@chakra-ui/react'
import { useState } from 'react'
import { Box, useColorMode } from '@chakra-ui/react'
import { CheckCircleIcon, AddIcon } from '@chakra-ui/icons'
import { User } from '../../__data__/model'
import { AddMissedButton, Avatar, Wrapper } from './style'
import { AddMissedButton, Avatar, Wrapper, NameOverlay } from './style'
export function getGravatarURL(email, user) {
if (!email) return void 0
@@ -18,15 +19,17 @@ export function getGravatarURL(email, user) {
export const UserCard = ({
student,
present,
onAddUser,
wrapperAS,
width
onAddUser = undefined,
wrapperAS = 'div',
width,
recentlyPresent = false
}: {
student: User
present: boolean
width?: string | number
onAddUser?: (user: User) => void
wrapperAS?: React.ElementType<any, keyof React.JSX.IntrinsicElements>;
recentlyPresent?: boolean
}) => {
const { colorMode } = useColorMode();
const [imageError, setImageError] = useState(false);
@@ -36,7 +39,7 @@ export const UserCard = ({
warn={!present}
as={wrapperAS}
width={width}
className={!present ? 'warn' : ''}
className={!present ? 'warn' : recentlyPresent ? 'recent' : ''}
>
<Avatar
src={imageError ? getGravatarURL(student.email, null) : (student.picture || getGravatarURL(student.email, null))}
@@ -46,22 +49,19 @@ export const UserCard = ({
}
}}
/>
<p style={{
marginTop: 6,
color: colorMode === 'light' ? 'inherit' : 'var(--chakra-colors-gray-100)'
}}>
{student.name || student.preferred_username}{' '}
</p>
<NameOverlay>
{student.name || student.preferred_username}
{present && (
<Box as="span" ml={2} display="inline-block" color={recentlyPresent ? "green.100" : "green.300"}>
<CheckCircleIcon boxSize={3} />
</Box>
)}
</NameOverlay>
{onAddUser && !present && (
<AddMissedButton onClick={() => onAddUser(student)}>
add
<AddMissedButton onClick={() => onAddUser(student)} aria-label="Отметить присутствие">
<AddIcon boxSize={3} />
</AddMissedButton>
)}
</Wrapper>
)
}
UserCard.defaultProps = {
wrapperAS: 'div',
onAddUser: void 0,
}