-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use unified util to create plugin canvas (#6524)
* refactor(plugins): remove plugin utils under plugins dir * refactor: use unified util to create plugin canvas * refactor(plugins): legend draw in independent canvas * test: update snapshots * refactor: remove useless method * fix: fix comments --------- Co-authored-by: antv <[email protected]>
- Loading branch information
Showing
19 changed files
with
321 additions
and
1,782 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
299 changes: 1 addition & 298 deletions
299
packages/g6/__tests__/snapshots/plugins/legend/click-again.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
299 changes: 1 addition & 298 deletions
299
packages/g6/__tests__/snapshots/plugins/legend/click.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
299 changes: 1 addition & 298 deletions
299
packages/g6/__tests__/snapshots/plugins/legend/mouseenter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
299 changes: 1 addition & 298 deletions
299
packages/g6/__tests__/snapshots/plugins/legend/mouseleave.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
299 changes: 1 addition & 298 deletions
299
packages/g6/__tests__/snapshots/plugins/legend/normal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { createPluginContainer, insertDOM } from '@/src/plugins/utils/dom'; | ||
|
||
describe('plugin dom utils', () => { | ||
it('createPluginContainer', () => { | ||
const el = createPluginContainer('test'); | ||
expect(el.getAttribute('class')).toBe('g6-test'); | ||
expect(el.style.position).toBe('absolute'); | ||
expect(el.style.display).toBe('block'); | ||
expect(el.style.inset).toBe('0px'); | ||
expect(el.style.height).toBe('100%'); | ||
expect(el.style.width).toBe('100%'); | ||
expect(el.style.overflow).toBe('hidden'); | ||
expect(el.style.pointerEvents).toBe('none'); | ||
}); | ||
|
||
it('createPluginContainer cover=false', () => { | ||
const el = createPluginContainer('test', false); | ||
expect(el.getAttribute('class')).toBe('g6-test'); | ||
expect(el.style.position).toBe('absolute'); | ||
expect(el.style.display).toBe('block'); | ||
expect(el.style.height).not.toBe('100%'); | ||
expect(el.style.width).not.toBe('100%'); | ||
expect(el.style.overflow).not.toBe('hidden'); | ||
expect(el.style.pointerEvents).not.toBe('none'); | ||
}); | ||
|
||
it('createPluginContainer with style', () => { | ||
const el = createPluginContainer('test', false, { color: 'red' }); | ||
expect(el.getAttribute('class')).toBe('g6-test'); | ||
expect(el.style.color).toBe('red'); | ||
}); | ||
|
||
it('insertDOM', () => { | ||
insertDOM('g6-test', 'div', { color: 'red' }, 'test', document.body); | ||
|
||
let el = document.getElementById('g6-test')!; | ||
expect(el).toBeTruthy(); | ||
expect(el.style.color).toBe('red'); | ||
expect(el.innerHTML).toBe('test'); | ||
|
||
insertDOM('g6-test', 'div', { color: 'red' }, 'new html', document.body); | ||
|
||
el = document.getElementById('g6-test')!; | ||
expect(el.innerHTML).toBe('new html'); | ||
|
||
el = insertDOM('g6-test'); | ||
expect(el.tagName.toLowerCase()).toBe('div'); | ||
expect(el.innerHTML).toBe(''); | ||
expect(el.parentNode).toBe(document.body); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.