Skip to content

Pug PR, WIP Don't merge #290

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Learn more: https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/guides/using-nextjs.md#shared-steps

module.exports = {
presets: ["@expo/next-adapter/babel"],
presets: ["@native-base/next-adapter/babel"],
plugins: [
["@babel/plugin-proposal-private-methods", { loose: true }],
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
Expand Down
38 changes: 18 additions & 20 deletions docs/3.0.x/customizing-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ Let's customise a Button component to include rounded borders and red colorSchem
## Basic

```tsx
import React from 'react';
import { NativeBaseProvider, extendTheme } from 'native-base';
import React from "react";
import { NativeBaseProvider, extendTheme } from "native-base";

export default function () {
const theme = extendTheme({
components: {
Button: {
// Can simply pass default props to change default behaviour of components.
baseStyle: {
rounded: 'md',
rounded: "md",
},
defaultProps: {
colorScheme: 'red',
colorScheme: "red",
},
},
Heading: {
// Can pass also function, giving you access theming tools
baseStyle: ({ colorMode }) => {
return {
color: colorMode === 'dark' ? 'red.300' : 'blue.300',
fontWeight: 'normal',
color: colorMode === "dark" ? "red.300" : "blue.300",
fontWeight: "normal",
};
},
},
Expand Down Expand Up @@ -78,22 +78,22 @@ When variant in defaultProps is `solid` the above button will use solid variant.
You can specify the base style of the component and use it across project.

```jsx isLive=true
import React from 'react';
import { Text, NativeBaseProvider, Center, extendTheme } from 'native-base';
import React from "react";
import { Text, NativeBaseProvider, Center, extendTheme } from "native-base";

export function Example() {
const theme = extendTheme({
components: {
Text: {
baseStyle: {
color: 'emerald.400'
color: "emerald.400",
},
defaultProps: { size: 'lg' },
defaultProps: { size: "lg" },
sizes: {
xl: { fontSize: '64px' },
lg: { fontSize: '32px' },
md: { fontSize: '16px' },
sm: { fontSize: '12px' },
xl: { fontSize: "64px" },
lg: { fontSize: "32px" },
md: { fontSize: "16px" },
sm: { fontSize: "12px" },
},
},
},
Expand All @@ -106,32 +106,31 @@ export function Example() {
</NativeBaseProvider>
);
}

```

## Adding Variants

You can also add the variants to the components and use it across project.

```jsx isLive=true
import React from 'react';
import React from "react";
import {
NativeBaseProvider,
Button,
extendTheme,
Center,
VStack,
} from 'native-base';
} from "native-base";

export function Example() {
const theme = extendTheme({
components: {
Button: {
variants: {
rounded: ({ colorScheme }: any) => {
rounded: ({ colorScheme }) => {
return {
bg: `${colorScheme}.500`,
rounded: 'full',
rounded: "full",
};
},
},
Expand All @@ -152,7 +151,6 @@ export function Example() {
</NativeBaseProvider>
);
}

```

<br />
Expand Down
38 changes: 18 additions & 20 deletions docs/3.1.x/customizing-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ Let's customise a Button component to include rounded borders and red colorSchem
## Basic

```tsx
import React from 'react';
import { NativeBaseProvider, extendTheme } from 'native-base';
import React from "react";
import { NativeBaseProvider, extendTheme } from "native-base";

export default function () {
const theme = extendTheme({
components: {
Button: {
// Can simply pass default props to change default behaviour of components.
baseStyle: {
rounded: 'md',
rounded: "md",
},
defaultProps: {
colorScheme: 'red',
colorScheme: "red",
},
},
Heading: {
// Can pass also function, giving you access theming tools
baseStyle: ({ colorMode }) => {
return {
color: colorMode === 'dark' ? 'red.300' : 'blue.300',
fontWeight: 'normal',
color: colorMode === "dark" ? "red.300" : "blue.300",
fontWeight: "normal",
};
},
},
Expand Down Expand Up @@ -78,22 +78,22 @@ When variant in defaultProps is `solid` the above button will use solid variant.
You can specify the base style of the component and use it across project.

```jsx isLive=true
import React from 'react';
import { Text, NativeBaseProvider, Center, extendTheme } from 'native-base';
import React from "react";
import { Text, NativeBaseProvider, Center, extendTheme } from "native-base";

export function Example() {
const theme = extendTheme({
components: {
Text: {
baseStyle: {
color: 'emerald.400'
color: "emerald.400",
},
defaultProps: { size: 'lg' },
defaultProps: { size: "lg" },
sizes: {
xl: { fontSize: '64px' },
lg: { fontSize: '32px' },
md: { fontSize: '16px' },
sm: { fontSize: '12px' },
xl: { fontSize: "64px" },
lg: { fontSize: "32px" },
md: { fontSize: "16px" },
sm: { fontSize: "12px" },
},
},
},
Expand All @@ -106,32 +106,31 @@ export function Example() {
</NativeBaseProvider>
);
}

```

## Adding Variants

You can also add the variants to the components and use it across project.

```jsx isLive=true
import React from 'react';
import React from "react";
import {
NativeBaseProvider,
Button,
extendTheme,
Center,
VStack,
} from 'native-base';
} from "native-base";

export function Example() {
const theme = extendTheme({
components: {
Button: {
variants: {
rounded: ({ colorScheme }: any) => {
rounded: ({ colorScheme }) => {
return {
bg: `${colorScheme}.500`,
rounded: 'full',
rounded: "full",
};
},
},
Expand All @@ -152,7 +151,6 @@ export function Example() {
</NativeBaseProvider>
);
}

```

<br />
Expand Down
68 changes: 34 additions & 34 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
const withFonts = require("next-fonts");
const { withNativebase } = require("@native-base/next-adapter");
const path = require("path");
const withMDX = require("@next/mdx")({
extension: /\.mdx?$/,
});
const { withExpo } = require("@expo/next-adapter");
const redirectsJSON = require("./redirects.json");
const withPlugins = require("next-compose-plugins");
const withTM = require("next-transpile-modules")([
"native-base",
"react-native-web",
"react-native-svg",
// "react-native-safe-area-context",
// "@react-aria/visually-hidden",
// "@react-native-aria/button",
// "@react-native-aria/checkbox",
// "@react-native-aria/combobox",
// "@react-native-aria/focus",
// "@react-native-aria/interactions",
// "@react-native-aria/listbox",
// "@react-native-aria/overlays",
// "@react-native-aria/radio",
// "@react-native-aria/slider",
// "@react-native-aria/tabs",
// "@react-native-aria/utils",
// "@react-stately/combobox",
// "@react-stately/radio",
]);

module.exports = withPlugins(
[
[withTM],
[withFonts],
[withMDX],
[withExpo, { projectRoot: __dirname }],
],
{
// const { withExpo } = require("@expo/next-adapter");
const redirectsJSON = require("./redirects.json");
module.exports = withNativebase({
dependencies: ["@native-base/icons"],
plugins: [[withMDX]],
nextConfig: {
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
// webpack: (config) => {
// config.resolve.alias = {
Expand Down Expand Up @@ -78,10 +54,16 @@ module.exports = withPlugins(
environment: process.env.ENVIRONMENT,
},
webpack: (config) => {
config.module.rules.push({
test: /\.ttf$/,
loader: "url-loader", // or directly file-loader
include: path.resolve(__dirname, "node_modules/@native-base/icons"),
});
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
"react-native$": "react-native-web",
// "@native-base/icons": "react-native-vector-icons",
};
config.resolve.extensions = [
".web.js",
Expand All @@ -95,5 +77,23 @@ module.exports = withPlugins(
locales: ["en"],
defaultLocale: "en",
},
}
);
// webpack: (config, options) => {
// config.module.rules.push({
// test: /\.ttf$/,
// loader: "url-loader", // or directly file-loader
// include: path.resolve(__dirname, "node_modules/@native-base/icons"),
// });
// config.resolve.alias = {
// ...(config.resolve.alias || {}),
// "react-native$": "react-native-web",
// };
// config.resolve.extensions = [
// ".web.js",
// ".web.ts",
// ".web.tsx",
// ...config.resolve.extensions,
// ];
// return config;
// },
},
});
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
"@babel/plugin-transform-typescript": "^7.16.1",
"@babel/traverse": "^7.16.3",
"@docsearch/react": "^3.0.0-alpha.42",
"@expo/vector-icons": "^12.0.5",
"@mdx-js/loader": "^1.6.22",
"@native-base/icons": "^0.0.11",
"@native-base/next-adapter": "^1.1.9",
"@next/mdx": "^12.0.4",
"@react-native-community/masked-view": "0.1.10",
"@react-navigation/drawer": "^6.1.8",
"@react-navigation/native": "5.0.8",
"@react-navigation/stack": "5.1.0",
"@types/react-native": "^0.66.8",
"codesandbox": "^2.2.3",
"expo-font": "^10.0.3",
"expo-linear-gradient": "^10.0.3",
"expo-modules-core": "^0.6.5",
"formik": "2.2.9",
"gray-matter": "^4.0.3",
"native-base": "3.3.3",
Expand All @@ -50,12 +50,12 @@
"react-native-svg": "^12.1.1",
"react-native-swipe-list-view": "^3.2.9",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^9.0.0",
"react-native-vector-icons": "^9.1.0",
"react-native-web": "^0.17.5",
"react-native-web-linear-gradient": "^1.1.2",
"react-navigation": "^4.4.4"
},
"devDependencies": {
"@expo/next-adapter": "3.1.12",
"@next/bundle-analyzer": "^12.0.4",
"@types/mdx-js__react": "^1.5.5",
"@types/node": "16.11.7",
Expand Down
Loading