Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding search and replace to datadocs #30

Merged
merged 2 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions datahub/webapp/__tests__/lib/data-doc/search.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { replaceStringIndices } from 'lib/data-doc/search';

const testString = 'the quick brown fox jumps over the lazy dog';

test('Replace empty case', () => {
expect(replaceStringIndices(testString, [], 'ze')).toBe(
'the quick brown fox jumps over the lazy dog'
);
});

test('Replace simple case', () => {
expect(replaceStringIndices(testString, [[0, 3]], 'ze')).toBe(
'ze quick brown fox jumps over the lazy dog'
);
});

test('Replace multiple case', () => {
expect(
replaceStringIndices(
testString,
[
[0, 3],
[31, 34],
],
'le'
)
).toBe('le quick brown fox jumps over le lazy dog');
expect(
replaceStringIndices(
testString,
[
[16, 19],
[40, 43],
],
'tiger'
)
).toBe('the quick brown tiger jumps over the lazy tiger');
});
4 changes: 2 additions & 2 deletions datahub/webapp/__tests__/lib/utils/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as utils from 'lib/utils/index';

// missing getSelectionRect, download, copy, scrollToElement, smoothScroll
// missing getSelectionRect, download, copy, smoothScroll

test('removeEmpty', () => {
expect(utils.removeEmpty({ notempty: 'test', empty: null })).toStrictEqual({
Expand All @@ -18,7 +18,7 @@ test('titleize', () => {

test('sleep', () => {
const mockFunction = jest.fn(() => {
console.log('mock function runs');
// console.log('mock function runs');
});

const testFunction = async () => {
Expand Down
55 changes: 55 additions & 0 deletions datahub/webapp/components/DataDoc/DataDoc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,58 @@
}
}
}

.DataDocSearchAndReplace {
position: fixed;
right: 60px;
z-index: 10;

border: var(--inner-border);
border-top: none;
border-bottom-left-radius: var(--border-radius);
border-bottom-right-radius: var(--border-radius);

background-color: var(--light-bg-color);

.position-info {
user-select: none;
font-size: var(--xsmall-text-size);
}

.datadoc-search-input {
border: var(--inner-border);
border-radius: var(--border-radius);

background-color: transparent;
width: 250px;
display: flex;
align-items: center;
padding: 4px;

&:focus-within {
border: var(--outer-border);
background-color: var(--bg-color);
}

.DebouncedInput {
flex: 1;
input {
padding: none;
border: none;
color: inherit;
font-size: var(--text-size);
}
}

.TextToggleButton {
font-size: var(--small-text-size);
color: var(--light-text-color);
font-weight: var(--bold-font);
user-select: none;

&.active {
color: var(--dark-text-color);
}
}
}
}
Loading