Skip to content

Commit

Permalink
Merge pull request #581 from lineupjs/release/v4.6.2
Browse files Browse the repository at this point in the history
Release v4.6.2
  • Loading branch information
sgratzl committed Jul 21, 2022
2 parents 2d5046b + c09ea50 commit e344292
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
19 changes: 19 additions & 0 deletions cypress/integration/custom_instance_id.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { withLineUp, waitReady, LineUpJSType, Taggle } from './utils/lineup';

describe('builder', () => {
let lineup: Taggle;
let lineUpJS: LineUpJSType;
before(
withLineUp((l, document) => {
lineUpJS = l;
const b = lineUpJS.builder([]);
b.instanceId('custom-instance-id');
lineup = b.buildTaggle(document.body);
waitReady(lineup);
})
);

it('default', () => {
cy.get('#lu-custom-instance-id'); // note the `lu-` prefix
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lineupjs",
"description": "LineUp is an interactive technique designed to create, visualize and explore rankings of items based on a set of heterogeneous attributes.",
"version": "4.6.1",
"version": "4.6.2",
"author": {
"name": "Samuel Gratzl",
"email": "sam@sgratzl.com",
Expand Down
9 changes: 9 additions & 0 deletions src/builder/LineUpBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,13 @@ export default class LineUpBuilder {
this.options.flags!.advancedUIFeatures = false;
return this;
}

/**
* identifier for this LineUp instance. by default a random id is generated.
* @default random string
*/
instanceId(instanceId: string) {
this.options.instanceId = instanceId;
return this;
}
}
8 changes: 8 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ export interface ILineUpOptions {
* @default false
*/
copyableRows: boolean;

/**
* identifier for this LineUp instance. by default a random id is generated.
* @default random string
*/
instanceId: string;
}

export interface ITaggleOptions extends ILineUpOptions {
Expand Down Expand Up @@ -305,5 +311,7 @@ export function defaultOptions(): ITaggleOptions {

ignoreUnsupportedBrowser: false,
copyableRows: true,

instanceId: Math.random().toString(36).slice(-8).substring(0, 3), // generate a random string with length 3
};
}
4 changes: 2 additions & 2 deletions src/styles/icons/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ $lu_icon_window_restore: '\f2d2';
@if $lu_use_font_awesome == true {
@include fa-icon();

font-family: 'Font Awesome 5 Free', serif;
font-weight: 900;
font-family: $fa-style-family, serif;
font-weight: $fa-style;
} @else {
display: inline-block;
font: normal normal normal 14px/1 lu-font, serif; // shortening font declaration
Expand Down
7 changes: 6 additions & 1 deletion src/ui/EngineRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ export default class EngineRenderer extends AEventDispatcher {

private readonly updateAbles: ((ctx: IRankingHeaderContext) => void)[] = [];
private zoomFactor = 1;
readonly idPrefix = `lu${Math.random().toString(36).slice(-8).substr(0, 3)}`; //generate a random string with length3;
readonly idPrefix;

private enabledHighlightListening = false;
readonly selectionIndicator: SelectionIndicator;

constructor(protected data: DataProvider, parent: HTMLElement, options: Readonly<ILineUpOptions>) {
super();
this.options = options;

this.idPrefix = this.options.instanceId
? `lu-${this.options.instanceId}`
: `lu-${Math.random().toString(36).slice(-8).substring(0, 3)}`;

this.node = parent.ownerDocument!.createElement('main');
this.node.id = this.idPrefix;
// FIXME inline
Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/CompositeChildrenDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class CompositeChildrenDialog extends APopup {

constructor(private readonly column: CompositeColumn, dialog: IDialogContext, private ctx: IRankingHeaderContext) {
super(dialog);
this.id = `.dialog${Math.random().toString(36).slice(-8).substr(0, 3)}`;
this.id = `.dialog${Math.random().toString(36).slice(-8).substring(0, 3)}`;
}

cleanUp(action: 'cancel' | 'confirm' | 'handled') {
Expand Down

0 comments on commit e344292

Please sign in to comment.