Skip to content

Commit

Permalink
chore(tsx): Tooltips - TypeScript, function based & split
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelurben committed Nov 6, 2024
1 parent 06c773d commit 21901cb
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 60 deletions.
23 changes: 20 additions & 3 deletions teamized/app/package-lock.json

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

1 change: 1 addition & 0 deletions teamized/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@babel/preset-env": "7.26.0",
"@babel/preset-react": "7.25.9",
"@babel/preset-typescript": "7.26.0",
"@types/bootstrap": "^5.2.10",
"@types/jquery": "3.5.32",
"babel-loader": "9.2.1",
"prettier": "3.3.3",
Expand Down
3 changes: 2 additions & 1 deletion teamized/app/src/components/common/dashboard/tile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { IconTooltip } from '../../tooltips.jsx';

import { IconTooltip } from '../tooltips/iconTooltip';

interface Props {
title: string | null;
Expand Down
20 changes: 20 additions & 0 deletions teamized/app/src/components/common/tooltips/iconTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { Tooltip } from './tooltip';

interface Props {
title: string;
icon: string;
className: string;
}

export function IconTooltip({
title,
icon = 'fas fa-info-circle',
className = '',
}: Partial<Props>) {
return (
<Tooltip className={className} title={title}>
<i className={'fa-fw ' + icon}></i>
</Tooltip>
);
}
29 changes: 29 additions & 0 deletions teamized/app/src/components/common/tooltips/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { useEffect, useRef } from 'react';
import { Tooltip as BSTooltip } from 'bootstrap';

interface Props {
title: string;
className: string;
children: React.ReactNode;
}

export function Tooltip({ title, className = '', children }: Partial<Props>) {
const tooltipRef = useRef<HTMLElement>(null);

useEffect(() => {
const tooltip = new BSTooltip(tooltipRef.current as HTMLElement);

return () => tooltip.dispose();
}, []);

return (
<abbr
className={className}
title={title}
data-bs-toggle="tooltip"
ref={tooltipRef}
>
{children}
</abbr>
);
}
3 changes: 2 additions & 1 deletion teamized/app/src/components/pages/calendars.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import * as Cache from '../../utils/cache.ts';
import * as Navigation from '../../utils/navigation.tsx';

import * as Dashboard from '../common/dashboard.tsx';
import { IconTooltip, Tooltip } from '../tooltips.jsx';
import { IconTooltip } from '../common/tooltips/iconTooltip';
import { Tooltip } from '../common/tooltips/tooltip';

const WEEKDAYS = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];

Expand Down
3 changes: 2 additions & 1 deletion teamized/app/src/components/pages/club.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import * as Dashboard from '../common/dashboard.tsx';
import * as Cache from '../../utils/cache.ts';
import * as Club from '../../utils/club.ts';
import * as Navigation from '../../utils/navigation.tsx';
import { IconTooltip } from '../tooltips.jsx';

import { IconTooltip } from '../common/tooltips/iconTooltip';

class ClubMembersTableRow extends React.Component {
constructor(props) {
Expand Down
3 changes: 2 additions & 1 deletion teamized/app/src/components/pages/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import * as Dashboard from '../common/dashboard.tsx';
import * as Utils from '../../utils/utils.ts';
import * as Settings from '../../utils/settings.ts';
import * as Navigation from '../../utils/navigation.tsx';
import { IconTooltip } from '../tooltips.jsx';

import { IconTooltip } from '../common/tooltips/iconTooltip';

export default class Page_Home extends React.Component {
constructor(props) {
Expand Down
3 changes: 2 additions & 1 deletion teamized/app/src/components/pages/team.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import * as Club from '../../utils/club.ts';
import * as Teams from '../../utils/teams';
import * as Navigation from '../../utils/navigation.tsx';
import * as Dashboard from '../common/dashboard.tsx';
import { IconTooltip, Tooltip } from '../tooltips.jsx';
import { IconTooltip } from '../common/tooltips/iconTooltip';
import { Tooltip } from '../common/tooltips/tooltip';

class TeamMembersTableRow extends React.Component {
constructor(props) {
Expand Down
3 changes: 2 additions & 1 deletion teamized/app/src/components/pages/teamlist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { waitingAlert } from '../../utils/alerts.ts';
import * as Teams from '../../utils/teams';
import * as Navigation from '../../utils/navigation.tsx';
import * as Dashboard from '../common/dashboard.tsx';
import { IconTooltip } from '../tooltips.jsx';

import { IconTooltip } from '../common/tooltips/iconTooltip';

class TeamTableRow extends React.Component {
constructor(props) {
Expand Down
3 changes: 2 additions & 1 deletion teamized/app/src/components/pages/todo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import * as Dashboard from '../common/dashboard.tsx';
import * as ToDo from '../../utils/todo.ts';
import * as Navigation from '../../utils/navigation.tsx';
import * as Cache from '../../utils/cache.ts';
import { IconTooltip, Tooltip } from '../tooltips.jsx';
import { IconTooltip } from '../common/tooltips/iconTooltip';
import { Tooltip } from '../common/tooltips/tooltip';

class ListViewItem extends React.Component {
constructor(props) {
Expand Down
2 changes: 1 addition & 1 deletion teamized/app/src/components/pages/workingtime.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import * as Navigation from '../../utils/navigation.tsx';
import * as WorkingTime from '../../utils/workingtime.ts';
import * as Cache from '../../utils/cache.ts';
import * as Dashboard from '../common/dashboard.tsx';
import { IconTooltip } from '../tooltips.jsx';
import * as Stats from '../../utils/workingtimestats.ts';
import {
roundDays,
localInputFormat,
ms2HoursMinutesSeconds,
seconds2HoursMinutesSeconds,
} from '../../utils/datetime.ts';
import { IconTooltip } from '../common/tooltips/iconTooltip';

class WorkSessionTableRow extends React.Component {
constructor(props) {
Expand Down
49 changes: 0 additions & 49 deletions teamized/app/src/components/tooltips.jsx

This file was deleted.

0 comments on commit 21901cb

Please sign in to comment.