Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/features.classroom/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from 'common.eslint';

export default config;
1 change: 1 addition & 0 deletions packages/features.classroom/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SubjectBadge } from './src';
41 changes: 41 additions & 0 deletions packages/features.classroom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "features.classroom",
"version": "0.0.0",
"type": "module",
"exports": {
".": "./index.ts"
},
"license": "MIT",
"scripts": {
"dev": "tsc --watch",
"lint": "eslint \"**/*.{ts,tsx}\""
},
"dependencies": {
"common.services": "*",
"@xipkg/badge": "2.0.12",
"@xipkg/utils": "1.8.0",
"@xipkg/tooltip": "2.1.0"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@types/node": "^20.3.1",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@xipkg/eslint": "3.2.0",
"@xipkg/tailwind": "0.8.1",
"@xipkg/typescript": "latest",
"common.eslint": "*",
"common.typescript": "*",
"eslint": "^9.19.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.18",
"globals": "^15.14.0",
"typescript": "~5.7.2",
"typescript-eslint": "^8.22.0"
},
"peerDependencies": {
"react": "19"
},
"description": "classroom features",
"author": "xi.effect"
}
1 change: 1 addition & 0 deletions packages/features.classroom/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SubjectBadge } from './ui';
38 changes: 38 additions & 0 deletions packages/features.classroom/src/ui/SubjectBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Badge } from '@xipkg/badge';
import { cn } from '@xipkg/utils';
import { useSubjectsById } from 'common.services';
import { Tooltip, TooltipContent, TooltipTrigger } from '@xipkg/tooltip';

type SubjectBadgePropsT = {
subject_id: number;
className?: string;
textStyles?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чуть более лаконично: textClassName

isTooltip?: boolean;
};

export const SubjectBadge = ({
subject_id,
className,
textStyles,
isTooltip = false,
}: SubjectBadgePropsT) => {
const { data: subject } = useSubjectsById(subject_id);

const badgeContent = (
<Badge
size="m"
className={cn('text-gray-80 bg-gray-5 rounded-lg border-none px-2 py-1', className)}
>
<span className={textStyles}>{subject?.name}</span>
</Badge>
);

if (!isTooltip) return badgeContent;

return (
<Tooltip delayDuration={1000}>
<TooltipTrigger asChild>{badgeContent}</TooltipTrigger>
<TooltipContent>{subject?.name}</TooltipContent>
</Tooltip>
);
};
1 change: 1 addition & 0 deletions packages/features.classroom/src/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SubjectBadge } from './SubjectBadge';
5 changes: 5 additions & 0 deletions packages/features.classroom/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"include": ["src/**/*", "../common.services/src/payments/useGetRecipientInvoiceByTutor.ts"],
"extends": ["common.typescript/tsconfig.app.json"],
"exclude": ["dist", "build", "node_modules"]
}
3 changes: 2 additions & 1 deletion packages/pages.classrooms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"features.group.add": "*",
"features.invites": "*",
"features.students.list": "*",
"features.table": "*"
"features.table": "*",
"features.classroom": "*"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
Expand Down
15 changes: 11 additions & 4 deletions packages/pages.classrooms/src/ui/components/cards/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { StatusBadge } from './StatusBadge';
import { useCurrentUser, useDeleteClassroom, useUserByRole } from 'common.services';
import { ClassroomPropsT } from '../../../types';
import { useNavigate, useSearch } from '@tanstack/react-router';
import { SubjectBadge } from './SubjectBadge';
import { SubjectBadge } from 'features.classroom';
import { Tooltip, TooltipContent, TooltipTrigger } from '@xipkg/tooltip';
import { Avatar, AvatarFallback, AvatarImage } from '@xipkg/avatar';

Expand Down Expand Up @@ -87,11 +87,18 @@ export const Card: React.FC<ClassroomPropsT & { deleted?: boolean }> = ({
onClick={handleClick}
className="hover:bg-gray-5 border-gray-30 bg-gray-0 relative flex cursor-pointer justify-between rounded-2xl border p-4"
>
<div className="flex flex-col gap-4">
<div className="mt-auto mr-8 flex items-center gap-2">
<div className="flex max-w-full flex-col gap-4">
<div className="mt-auto mr-8 flex w-full max-w-[calc(100%-32px)] items-center gap-2">
<StatusBadge status={status} kind={kind} deleted={deleted} />

{subject_id && <SubjectBadge subject_id={subject_id} />}
{subject_id && (
<SubjectBadge
subject_id={subject_id}
className="flex-1 overflow-hidden"
textStyles="truncate max-w-full"
isTooltip
/>
)}
</div>
<div className="flex flex-row gap-2">
{kind === 'individual' && (
Expand Down
20 changes: 0 additions & 20 deletions packages/pages.classrooms/src/ui/components/cards/SubjectBadge.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const CardsGridTutor = () => {

return (
<div ref={parentRef} className="h-[calc(100vh-204px)] w-full overflow-auto pr-4">
<div className="max-xs:gap-4 grid grid-cols-1 gap-8 min-[550px]:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
<div className="grid grid-cols-[repeat(auto-fit,minmax(320px,1fr))] gap-8">
{items.map((classroom) => (
<div key={classroom.id} className="classroom-card">
<Card {...classroom} />
Expand Down
1 change: 1 addition & 0 deletions packages/pages.main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"features.group.add": "*",
"features.materials.duplicate": "*",
"features.invoice.card": "*",
"features.classroom": "*",
"pages.classrooms": "*",
"pages.materials": "*",
"react-hook-form": "^7.55.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Arrow, Conference } from '@xipkg/icons';
import { Tooltip, TooltipContent, TooltipTrigger } from '@xipkg/tooltip';
import { Avatar, AvatarFallback, AvatarImage } from '@xipkg/avatar';
import { useCurrentUser, useUserByRole } from 'common.services';
import { SubjectBadge } from './SubjectBadge';
import { SubjectBadge } from 'features.classroom';

type UserAvatarPropsT = {
classroom: IndividualClassroomT;
Expand Down Expand Up @@ -85,7 +85,12 @@ export const Classroom = ({ classroom, isLoading }: ClassroomProps) => {
</Tooltip>

{classroom.subject_id ? (
<SubjectBadge subject_id={classroom.subject_id} />
<SubjectBadge
subject_id={classroom.subject_id}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы всё же в качестве стиля для написания пропса использовал camelCase

Это в целом не ошибка, но идеально использовать snake_case только для непосредственно полей из api, а тут мы уже работаем с пропсами самого компонента

isTooltip
className="max-w-[calc(100%-32px)] overflow-hidden"
textStyles="truncate max-w-full"
/>
) : (
<div className="h-7 w-7" />
)}
Expand Down
17 changes: 0 additions & 17 deletions packages/pages.main/src/ui/components/Classrooms/SubjectBadge.tsx

This file was deleted.

70 changes: 70 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading