Skip to content

Commit

Permalink
Add a thousandth delimiter for text in annotations in struct view
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Mar 7, 2024
1 parent 4f90de5 commit 2007475
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added basic support for `TypedArray`s and `Set` values in `struct`, `signature` and `table` views
- Added `'only'` value for `darkmode` option of `Widget` & `App`, which forces to use dark mode with no option for a user to switch to light mode
- Added `scalarCol` option for `table` view to display the row value as the first cell
- Added a thousandth delimiter for text in annotations in `struct` view
- Modified the badge view to enable passing all options via config, in addition to data
- Fixed the highlighting of Jora assertions
- Fixed displaying supported syntaxes in view's showcase for `source` view
Expand Down
11 changes: 10 additions & 1 deletion src/views/struct/render-annotations.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createElement } from '../../core/utils/dom.js';
import { numDelim } from '../../core/utils/html.js';

const styles = ['none', 'default', 'badge'];

Expand Down Expand Up @@ -35,7 +36,15 @@ export default function renderAnnotations(annotations) {
class: elClassName,
href,
target: external ? '_blank' : undefined
}, hasText ? [text] : undefined);
});

if (hasText) {
if (/\d{4}/.test(text)) {
annotationEl.innerHTML = numDelim(text);
} else {
annotationEl.append(text);
}
}

if (icon) {
annotationEl.classList.add('icon');
Expand Down
17 changes: 11 additions & 6 deletions src/views/struct/style/annotation.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.view-struct .value-annotations {
margin-left: 6px;
}
.view-struct .value + .value-annotations {
margin-left: 1.5ex;
}

.view-struct .value-annotation {
display: inline-block;
vertical-align: middle;
Expand Down Expand Up @@ -33,12 +40,6 @@
.view-struct .value-annotation.before + .value {
margin-left: 2px;
}
.view-struct .value-annotations {
margin-left: 6px;
}
.view-struct .value + .value-annotations {
margin-left: 1.5ex;
}

.view-struct .value-annotation.style-none,
.view-struct .value-annotation.style-default {
Expand Down Expand Up @@ -73,3 +74,7 @@
text-decoration: underline;
text-decoration-color: #89a0bd88;
}

.view-struct .value-annotation .num-delim {
padding-left: 2px;
}

0 comments on commit 2007475

Please sign in to comment.