-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(widget): make only one flat set of params (#3318)
* docs(widget): typedoc for widget lib * fix(widget): simplify metaData and use default value for it * refactor(widget): make only one flat set of params * chore: fix tests * refactor: replace metaData just by appKey * chore: add defaults for CowSwapWidgetParams docs * chore: change widget and height types * chore: fix docs * chore: remove dynamicHeightEnabled * chore: fix docs
- Loading branch information
Showing
22 changed files
with
284 additions
and
243 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
4 changes: 2 additions & 2 deletions
4
apps/cowswap-frontend/src/modules/injectedWidget/hooks/useInjectedWidgetMetaData.ts
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { useAtomValue } from 'jotai' | ||
|
||
import { InjectedWidgetMetaData, injectedWidgetMetaDataAtom } from '../state/injectedWidgetMetaDataAtom' | ||
import { CowSwapWidgetMetaData, injectedWidgetMetaDataAtom } from '../state/injectedWidgetMetaDataAtom' | ||
|
||
export function useInjectedWidgetMetaData(): InjectedWidgetMetaData | null { | ||
export function useInjectedWidgetMetaData(): CowSwapWidgetMetaData { | ||
return useAtomValue(injectedWidgetMetaDataAtom) | ||
} |
4 changes: 2 additions & 2 deletions
4
apps/cowswap-frontend/src/modules/injectedWidget/hooks/useInjectedWidgetParams.ts
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { useAtomValue } from 'jotai' | ||
|
||
import type { CowSwapWidgetAppParams } from '@cowprotocol/widget-lib' | ||
import type { CowSwapWidgetParams } from '@cowprotocol/widget-lib' | ||
|
||
import { injectedWidgetParamsAtom } from '../state/injectedWidgetParamsAtom' | ||
|
||
export function useInjectedWidgetParams(): CowSwapWidgetAppParams { | ||
export function useInjectedWidgetParams(): CowSwapWidgetParams { | ||
return useAtomValue(injectedWidgetParamsAtom) | ||
} |
9 changes: 6 additions & 3 deletions
9
apps/cowswap-frontend/src/modules/injectedWidget/state/injectedWidgetMetaDataAtom.ts
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { atom } from 'jotai' | ||
|
||
export interface InjectedWidgetMetaData { | ||
export interface CowSwapWidgetMetaData { | ||
appKey: string | ||
url: string | ||
} | ||
|
||
export const injectedWidgetMetaDataAtom = atom<InjectedWidgetMetaData | null>(null) | ||
const DEFAULT_INJECTED_WIDGET_META_DATA: CowSwapWidgetMetaData = { | ||
appKey: 'DEFAULT_INJECTED_WIDGET', | ||
} | ||
|
||
export const injectedWidgetMetaDataAtom = atom<CowSwapWidgetMetaData>(DEFAULT_INJECTED_WIDGET_META_DATA) |
4 changes: 2 additions & 2 deletions
4
apps/cowswap-frontend/src/modules/injectedWidget/state/injectedWidgetParamsAtom.ts
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { atom } from 'jotai' | ||
|
||
import type { CowSwapWidgetAppParams } from '@cowprotocol/widget-lib' | ||
import type { CowSwapWidgetParams } from '@cowprotocol/widget-lib' | ||
|
||
export const injectedWidgetParamsAtom = atom<CowSwapWidgetAppParams>({}) | ||
export const injectedWidgetParamsAtom = atom<CowSwapWidgetParams>({}) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,22 +3,12 @@ | |
<head> | ||
<meta charset="UTF-8"> | ||
<title>CoWSwap Widget demo</title> | ||
<script src="https://cdn.jsdelivr.net/npm/@cowprotocol/[email protected].2/index.iife.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@cowprotocol/[email protected].3/index.iife.js"></script> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script> | ||
cowSwapWidget.cowSwapWidget({ | ||
container: document.getElementById("app"), | ||
width: 400, | ||
height: 600, | ||
metaData: { | ||
appKey: 'test', | ||
appUrl: 'test', | ||
} | ||
}, { | ||
env: 'dev' | ||
}) | ||
cowSwapWidget.cowSwapWidget(document.getElementById("app")) | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.