-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce useWidgetMode hook and update theme handling
- Loading branch information
1 parent
3473f6a
commit e9632a8
Showing
7 changed files
with
39 additions
and
42 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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import type { CowProtocolTheme } from '@cowprotocol/ui' | ||
|
||
declare module 'styled-components' { | ||
export interface CowSwapDefaultTheme extends CowProtocolTheme { | ||
isInjectedWidgetMode: boolean | ||
} | ||
export interface CowSwapDefaultTheme extends CowProtocolTheme {} | ||
|
||
export interface DefaultTheme extends CowSwapDefaultTheme {} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { isInjectedWidget } from '@cowprotocol/common-utils' | ||
import { WidgetThemeMode } from '@cowprotocol/types' | ||
|
||
export function useWidgetMode(): WidgetThemeMode { | ||
const isWidget = isInjectedWidget() | ||
const isIframe = window.self !== window.top | ||
const isStandalone = !isWidget && !isIframe | ||
const isInjectedWidgetMode = isWidget | ||
|
||
return { | ||
isInjectedWidgetMode, | ||
isStandalone, | ||
isWidget, | ||
isIframe, | ||
} | ||
} |
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