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

feat: responsive compnent props support #2197

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ toc: false

import { Canvas, Meta, Story } from '@storybook/addon-docs';
import Responsiveness from '../../extra-components/nativewind/Responsive';

import { kitchensink } from '../../extra-components/nativewind/appConfig.tsx';

<Meta title="with-nativewind/Apps/Dashboard App" />

# Dashboard App

This [Dashboard App](https://ui-example-nativewind.vercel.app/) is built using `gluestack-ui` components styled with `NativeWind`.

<Responsiveness />
<Responsiveness {...kitchensink} />

GitHub link for this [Dashboard App](https://github.com/gluestack/ui-example-nativewind).
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ toc: false
---

import { Canvas, Meta, Story } from '@storybook/addon-docs';
import Responsiveness from '../../extra-components/nativewind/ResponsiveStarterKit';
import Responsiveness from '../../extra-components/nativewind/Responsive';
import { starterKit } from '../../extra-components/nativewind/appConfig';


<Meta title="with-nativewind/Apps/Starter Kit" />
Expand All @@ -14,6 +15,6 @@ import Responsiveness from '../../extra-components/nativewind/ResponsiveStarterK

This [Starter Kit](https://gluestack-ui-starter-kits.vercel.app/) is built using `gluestack-ui` components styled with `NativeWind`.

<Responsiveness />
<Responsiveness {...starterKit} />

GitHub link for this [Starter Kit](https://github.com/gluestack/gluestack-ui-starter-kits).
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ toc: false
---

import { Canvas, Meta, Story } from '@storybook/addon-docs';
import Responsiveness from '../../extra-components/nativewind/ResponsiveStorybook';

import Responsiveness from '../../extra-components/nativewind/Responsive';
import { storybook } from '../../extra-components/nativewind/appConfig.tsx';

<Meta title="with-nativewind/Apps/Storybook App" />

# Storybook App

This is a [Storybook App](https://storybook-v2.gluestack.io/?path=/story/stories-accordion--accordion) of `gluestack-ui` components styled with `NativeWind`.

<Responsiveness />
<Responsiveness {...storybook} />

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,38 @@ import React, { useRef, useState } from 'react';
import NextImage from 'next/image';
import { Expand } from '../../apps/dashboard-app/Expand';
import { Resizable } from 're-resizable';
import kitchensink from './kitchensink';

//function to detect if the user is on a web browser
function checkPlatform() {
function checkPlatform({
android,
ios,
uri,
}: {
android: string;
ios: string;
uri: string;
}) {
if (/android/i.test(navigator.userAgent)) {
window.location.href = `exp://u.expo.dev/update/${kitchensink.updateIds.android}`;
window.location.href = `exp://u.expo.dev/update/${android}`;
} else if (/iPad|iPhone|iPod/i.test(navigator.userAgent)) {
window.location.href = `exp://u.expo.dev/update/${kitchensink.updateIds.ios}`;
window.location.href = `exp://u.expo.dev/update/${ios}`;
} else if (typeof window !== 'undefined' && typeof document !== 'undefined') {
window.open('https://ui-example-nativewind.vercel.app/');
window.open(uri);
}
}

function Responsiveness() {
function Responsiveness({
iframeUri,
qrCodeUri,
updateIds,
}: {
iframeUri: string;
qrCodeUri: string;
updateIds: {
android: string;
ios: string;
};
}) {
const resizableRef = useRef<any>(null);
const [isMobile, setIsMobile] = useState(true);
return (
Expand Down Expand Up @@ -148,7 +166,7 @@ function Responsiveness() {

<Box h="100%" w="100%" overflow="hidden">
<iframe
src="https://ui-example-nativewind.vercel.app/"
src={iframeUri}
title="NativeBase v3 Dashboard Example"
style={{
transformOrigin: '0px 0px',
Expand Down Expand Up @@ -269,7 +287,13 @@ function Responsiveness() {
display: 'flex',
},
}}
onPress={checkPlatform}
onPress={() =>
checkPlatform({
android: updateIds?.android,
ios: updateIds?.ios,
uri: iframeUri,
})
}
>
<OpenInNewIcon />
<Text
Expand Down Expand Up @@ -340,12 +364,7 @@ function Responsiveness() {
},
}}
>
<NextImage
alt="qr-code"
width={90}
height={90}
src={`https://qr.expo.dev/eas-update?slug=exp&projectId=42cce9b5-9fbe-4572-92ba-fc43b2437a85&groupId=432e8802-2a73-4498-8301-5ac41664678e`}
/>
<NextImage alt="qr-code" width={90} height={90} src={qrCodeUri} />
</Box>
</Box>
</Box>
Expand Down
Loading
Loading