-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #711 from XYOracleNetwork/feature/dynamic-share
Meta-Server Share Components
- Loading branch information
Showing
8 changed files
with
74 additions
and
1 deletion.
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,3 +1,4 @@ | ||
export * from './button/index.ts' | ||
export * from './icons/index.ts' | ||
export * from './meta-server/index.ts' | ||
export * from './out/index.ts' |
23 changes: 23 additions & 0 deletions
23
packages/sdk/packages/share/src/meta-server/dynamic-share/DynamicShareImage.tsx
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,23 @@ | ||
import React from 'react' | ||
import { Helmet } from 'react-helmet' | ||
|
||
/** | ||
* The props for the DynamicShareImage component. | ||
*/ | ||
export interface DynamicShareImageProps { | ||
/** | ||
* The URL of the share image for the page. | ||
*/ | ||
image: string | ||
} | ||
|
||
/** | ||
* Used in conjunction with the XY Meta Server to dynamically set the share image for a page. | ||
*/ | ||
export const DynamicShareImage: React.FC<DynamicShareImageProps> = ({ image }) => { | ||
return ( | ||
<Helmet> | ||
<meta property="xyo:og:image" content={image} /> | ||
</Helmet> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/sdk/packages/share/src/meta-server/dynamic-share/index.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './DynamicShareImage.tsx' |
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,2 @@ | ||
export * from './dynamic-share/index.ts' | ||
export * from './live-share/index.ts' |
39 changes: 39 additions & 0 deletions
39
packages/sdk/packages/share/src/meta-server/live-share/HideParentsFlexbox.tsx
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,39 @@ | ||
import { FlexBoxProps, FlexGrowRow } from '@xylabs/react-flexbox' | ||
import { WithChildren } from '@xylabs/react-shared' | ||
import React, { useEffect } from 'react' | ||
|
||
export const HideParentsFlexbox: React.FC<WithChildren & FlexBoxProps> = ({ children, ...props }) => { | ||
useEffect(() => { | ||
const style = document.createElement('style') | ||
document.head.append(style) | ||
style.innerHTML = ` | ||
/** make all elements hidden */ | ||
* { | ||
visibility: hidden; | ||
} | ||
/** move the preview area to the top of the page */ | ||
#preview-area { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
z-index: 9999; | ||
} | ||
/** make the preview area and all its children visible */ | ||
#preview-area * { | ||
visibility: visible; | ||
}` | ||
|
||
return () => { | ||
style.remove() | ||
} | ||
}, []) | ||
|
||
return ( | ||
<FlexGrowRow alignItems="stretch" id="preview-area" justifyContent="start" {...props}> | ||
{children} | ||
</FlexGrowRow> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/sdk/packages/share/src/meta-server/live-share/index.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './HideParentsFlexbox.tsx' |
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