Skip to content

Commit

Permalink
feat: Migrated from jquery-bootstrap tooltip to css based tooltip (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik authored Apr 24, 2024
2 parents 34407ef + d950bb3 commit fcb4723
Show file tree
Hide file tree
Showing 5 changed files with 1,589 additions and 1,298 deletions.
3 changes: 1 addition & 2 deletions apps/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@
"@storybook/react": "^6.5.13",
"@tanstack/react-query": "^4.14.5",
"axios": "1.6.2",
"bootstrap": "4.6.0",
"cooltipz-css": "^2.3.0",
"cross-env": "^7.0.3",
"file-saver": "^2.0.5",
"handsontable": "^13.1.0",
"http-server": "^14.1.1",
"jquery": "^3.7.1",
"moment": "^2.29.4",
"react": "18.2.0",
"react-datepicker": "^4.21.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.handsontable td {
overflow: unset !important;
}
.custom-cell {
text-align: center;
padding: 5px !important;
Expand All @@ -12,7 +15,6 @@
cursor: pointer;
text-align: center;
padding: 5px !important;

}
.del-btn {
color: #fff;
Expand All @@ -24,6 +26,10 @@
.del-btn:hover {
background-color: #d00;
}
.del-btn svg:hover {
fill: #fff;
cursor: pointer
}

.list-wrapper {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.09);
Expand Down
15 changes: 5 additions & 10 deletions apps/widget/src/components/Common/Table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint-disable max-len */
import { forwardRef } from 'react';
import { HotTable } from '@handsontable/react';
// eslint-disable-next-line id-length
import $ from 'jquery';

import 'cooltipz-css/cooltipz.min.css';
import {
TextCellType,
DateCellType,
Expand Down Expand Up @@ -60,19 +58,16 @@ Handsontable.renderers.registerRenderer(
function renderer(instance, TD, row, col, prop, value, cellProperties) {
const name = String(prop).replace('record.', '');
TD.classList.add('custom-cell');
$(TD).tooltip('dispose');
TD.ariaLabel = '';
const soureData = instance.getSourceDataAtRow(row) as IRecord;
let fieldValue = typeof soureData.record[name] === 'undefined' ? '' : soureData.record[name];
if (typeof fieldValue === 'string' && fieldValue.length > name.length + 20)
fieldValue = value.substring(0, name.length + 20) + '...';

if (soureData.errors && soureData.errors[name]) {
$(TD).tooltip({
container: 'body',
trigger: 'hover',
title: soureData.errors[name],
placement: 'auto',
});
TD.ariaLabel = soureData.errors[name];
TD.dataset.cooltipzDir = row < 5 ? 'bottom' : 'top';
TD.dataset.cooltipzSize = 'fit';
}

if (soureData.updated && soureData.updated[name]) {
Expand Down
2 changes: 0 additions & 2 deletions apps/widget/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from 'react';
import { App } from './components/App';
import { createRoot } from 'react-dom/client';
import reportWebVitals from './reportWebVitals';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap/dist/js/bootstrap.bundle.min';

const container = document.getElementById('root');
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down
Loading

0 comments on commit fcb4723

Please sign in to comment.