-
Notifications
You must be signed in to change notification settings - Fork 0
90: fix classroom card badge layout and add tooltips #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import config from 'common.eslint'; | ||
|
|
||
| export default config; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { SubjectBadge } from './src'; |
| 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" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { SubjectBadge } from './ui'; |
| 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; | ||
| 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> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { SubjectBadge } from './SubjectBadge'; |
| 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"] | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" /> | ||
| )} | ||
|
|
||
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Чуть более лаконично: textClassName