-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bar position option, experimental Cypress test browser support (#23)
* Add bar position option, experimental Cypress test browser support * Fix tests
- Loading branch information
Showing
10 changed files
with
310 additions
and
112 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
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,41 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { ScriptType } from '../types'; | ||
|
||
export default function ScriptTypeSelect({ | ||
value, | ||
onChange, | ||
color, | ||
fontSize, | ||
shortDescription, | ||
}: { | ||
value: ScriptType; | ||
onChange: (val: ScriptType) => void; | ||
color?: string; | ||
fontSize?: number; | ||
shortDescription?: boolean; | ||
}) { | ||
return ( | ||
<select | ||
className="link-button mr-4" | ||
style={{ | ||
backgroundColor: '#080a0b', | ||
color: color ?? 'white', | ||
border: 'none', | ||
outline: 'none', | ||
fontSize, | ||
}} | ||
onChange={(e) => onChange(e.target.value as ScriptType)} | ||
value={value} | ||
> | ||
<option value={ScriptType.Playwright}> | ||
Playwright{!shortDescription ? ' Library' : ''} | ||
</option> | ||
<option value={ScriptType.Puppeteer}> | ||
Puppeteer{!shortDescription ? ' Library' : ''} | ||
</option> | ||
<option value={ScriptType.Cypress}> | ||
Cypress{!shortDescription ? ' Library' : ''} | ||
</option> | ||
</select> | ||
); | ||
} |
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,49 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { | ||
setPreferredLibraryStorage, | ||
setPreferredBarPositionStorage, | ||
localStorageGet, | ||
} from './utils'; | ||
import { ScriptType, BarPosition } from '../types'; | ||
|
||
export function usePreferredLibrary() { | ||
const [preferredLibrary, setPreferredLibrary] = useState<ScriptType | null>( | ||
null | ||
); | ||
|
||
useEffect(() => { | ||
localStorageGet(['preferredLibrary']).then( | ||
({ preferredLibrary: storedPreferredLibrary }) => { | ||
setPreferredLibrary(storedPreferredLibrary); | ||
} | ||
); | ||
}, []); | ||
|
||
const setPreferredLibraryWithStorage = (library: ScriptType) => { | ||
setPreferredLibrary(library); | ||
setPreferredLibraryStorage(library); | ||
}; | ||
|
||
return [preferredLibrary, setPreferredLibraryWithStorage] as const; | ||
} | ||
|
||
export function usePreferredBarPosition(defaultPosition: BarPosition) { | ||
const [preferredBarPosition, setPreferredBarPosition] = | ||
useState<BarPosition | null>(defaultPosition); | ||
|
||
useEffect(() => { | ||
localStorageGet(['preferredBarPosition']).then( | ||
({ preferredBarPosition: storedPreferredBarPosition }) => { | ||
setPreferredBarPosition(storedPreferredBarPosition ?? defaultPosition); | ||
} | ||
); | ||
}, []); | ||
|
||
const setPreferredBarPositionWithStorage = (barPosition: BarPosition) => { | ||
setPreferredBarPosition(barPosition); | ||
setPreferredBarPositionStorage(barPosition); | ||
}; | ||
|
||
return [preferredBarPosition, setPreferredBarPositionWithStorage] as const; | ||
} |
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.