Skip to content

Commit

Permalink
fix: No result message styling (#23)
Browse files Browse the repository at this point in the history
* "No Results" message position and style
* Updated build and README.md file
  • Loading branch information
andres-rubio-go authored Jun 20, 2023
1 parent 48247c9 commit ea68b10
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ possible in your explanation and we'll address it as quick as we can.
yarn build
```
If yarn build fails try using:
```shell
bin/build
```
4. **Building your code automatically in the background**
Recommended: Webpack can detect changes and build automatically
Expand Down
2 changes: 1 addition & 1 deletion report_table.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion report_table.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/layout_auto.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
z-index: 1;
}

table.reportTable {
table.reportTable {
width: 100%;
table-layout: auto;
opacity: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/layout_fixed.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ table.reportTable th {
overflow: hidden;
text-overflow: ellipsis;
white-space: break-spaces;
}
}

table.reportTable td {
max-width: 0;
Expand Down
51 changes: 32 additions & 19 deletions src/report_table.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {VisPluginTableModel} from './vis_table_plugin';
import * as d3 from './d3loader';

const NO_RESULTS_MESSAGE = 'No results';

const themes = {
traditional: require('./theme_traditional.css'),
looker: require('./theme_looker.css'),
Expand Down Expand Up @@ -32,27 +34,38 @@ const loadStylesheet = function (link) {
};

const renderTableNoResults = function () {
// Locate visContainer
const visContainer = d3.select('#visContainer').node();
const visContainer = document.querySelector('#visContainer');
const noResultsMessage = buildNoResultsContainer();

// If no visContainer add it and print no results messaging
// else clear contents and add no results messaging
if (!visContainer) {
d3.select('#vis')
.append('div')
.attr('id', 'visContainer')
.style('height', '80vh')
.style('display', 'flex')
.style('align-items', 'center')
.style('justify-content', 'center')
.style('font-size', '13px')
.style('font-family', '"Open Sans", "Helvetica", "Arial", sans-serif')
.style('text-anchor', 'middle') // legacy
.style('text-align', 'center') // legacy
.text('No Results');
} else {
d3.select('#visContainer').html('').text('No Results');
// If visContainer exists remove to add a new with styling for no results message
if (visContainer) {
visContainer.parentNode.removeChild(visContainer);
}

// Append No Results message
document.querySelector('#vis').append(noResultsMessage);
};

const buildNoResultsContainer = () => {
const noResultsMessage = document.createElement('div');

noResultsMessage.setAttribute('id', 'visContainer');
// Set cssText property. TODO - Set a class and import stylesheet
noResultsMessage.style.cssText = `
display: flex;
height: 100%;
justify-content: center;
align-items: center;
font-family: 'Roboto';
text-anchor: middle;
text-align: center;
font-size: 1rem;
font-weight: 500;
color: rgb(38, 45, 51);
`;
noResultsMessage.innerText = NO_RESULTS_MESSAGE;

return noResultsMessage;
};

const buildReportTable = function (
Expand Down

0 comments on commit ea68b10

Please sign in to comment.