Skip to content

Commit

Permalink
fix: border in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktorrudzki committed Apr 18, 2024
2 parents 044bec0 + c54fb9f commit a19f559
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 12 deletions.
21 changes: 21 additions & 0 deletions src/components/Button/SecondaryButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { fireEvent, screen } from '@testing-library/react-native';

import { SecondaryButton } from '@/components/Button';
import renderWithTheme from '@/tests/renderWithTheme';

const onPress = jest.fn();

describe('SecondaryButton component tests', () => {
it('properly renders button with provided text', () => {
renderWithTheme(<SecondaryButton text="test" onPress={onPress} />);

expect(screen.getByText('test')).toBeDefined();
});
it('calls provieded onPress method', () => {
renderWithTheme(<SecondaryButton text="test" onPress={onPress} />);

fireEvent(screen.getByText('test'), 'press');

expect(onPress).toHaveBeenCalledTimes(1);
});
});
51 changes: 51 additions & 0 deletions src/components/Button/SecondaryButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import { Pressable, StyleSheet, Text } from 'react-native';
import { universalColors } from 'style';

import { useTheme } from '@/hooks';

type Props = React.ComponentProps<typeof Pressable> & {
text: string;
onPress: () => void;
};

const SecondaryButton = ({ text, onPress, ...passThroughProps }: Props) => {
const { themedStyles, theme } = useTheme();

return (
<Pressable
{...passThroughProps}
style={{
...styles.button,
borderWidth: 1,
backgroundColor: themedStyles.background,
borderColor:
theme === 'light' ? universalColors.lightSilver : undefined,
}}
onPress={onPress}
>
<Text style={{ ...styles.text, color: themedStyles.textButtonSecondary }}>
{text}
</Text>
</Pressable>
);
};

export default SecondaryButton;

const styles = StyleSheet.create({
button: {
justifyContent: 'center',
alignItems: 'center',
width: 291,
height: 44,
borderRadius: 10,
},

text: {
fontSize: 12,
lineHeight: 15,
fontWeight: '500',
textAlign: 'center',
},
});
1 change: 1 addition & 0 deletions src/components/Button/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as PrimaryButton } from './PrimaryButton';
export { default as SecondaryButton } from './SecondaryButton';
3 changes: 2 additions & 1 deletion src/screens/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import { StyleSheet, Text, View } from 'react-native';
import { globalStyles } from 'style';

import { PrimaryButton } from '@/components/Button';
import { PrimaryButton, SecondaryButton } from '@/components/Button';
import { ConversationTile } from '@/components/ConversationTile';
import { TextInput } from '@/components/TextInput';
import { SwitchTheme } from '@/components/Theme';
Expand Down Expand Up @@ -66,6 +66,7 @@ const Home = ({ navigation }: Props) => {
text="pobierz dane"
onPress={invoke}
/>
<SecondaryButton text="secondary button" onPress={() => {}} />
</View>
);
};
Expand Down
2 changes: 2 additions & 0 deletions style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const darkColors = {
background: '#2F2F2F',
text: '#FFFFFF',
textSecondary: '#FFFFFF',
textButtonSecondary: '#FFFFFF',
inputBackground: '#2d2d2d',
inputBorder: '#c7c4d6',
};
Expand All @@ -36,6 +37,7 @@ export const lightColors = {
background: '#FFFFFF',
text: '#010000',
textSecondary: '#73828A',
textButtonSecondary: '#7A7A7A',
inputBackground: '#f0f0f0',
inputBorder: '#c7c4d6',
};
28 changes: 17 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.24.4.tgz#1a4653c0cf8ac46441ec406dece6e9bc590356a4"
integrity sha512-B8q7Pz870Hz/q9UgP8InNpY01CSLDSCyqX7zcRuv3FcPl87A2G17lASroHWaCtbdIcbYzOZ7kWmXFKbijMSmFg==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.24.4"
"@babel/helper-create-class-features-plugin" "^7.24.4"
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-syntax-class-static-block" "^7.14.5"
Expand Down Expand Up @@ -1022,11 +1023,13 @@
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.24.4.tgz#46dbbcd608771373b88f956ffb67d471dce0d23b"
integrity sha512-7Kl6cSmYkak0FK/FXjSEnLJ1N9T/WA2RkMhu17gZ/dsxKJUuTYNIylahPTzqpLyJN4WhDif8X0XK1R8Wsguo/A==
dependencies:
"@babel/compat-data" "^7.24.4"
"@babel/compat-data" "^7.24.4"
"@babel/helper-compilation-targets" "^7.23.6"
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/helper-validator-option" "^7.23.5"
"@babel/plugin-bugfix-firefox-class-in-computed-class-key" "^7.24.4"
"@babel/plugin-bugfix-firefox-class-in-computed-class-key" "^7.24.4"
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.24.1"
"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.24.1"
"@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly" "^7.24.1"
Expand Down Expand Up @@ -1054,8 +1057,10 @@
"@babel/plugin-transform-async-to-generator" "^7.24.1"
"@babel/plugin-transform-block-scoped-functions" "^7.24.1"
"@babel/plugin-transform-block-scoping" "^7.24.4"
"@babel/plugin-transform-block-scoping" "^7.24.4"
"@babel/plugin-transform-class-properties" "^7.24.1"
"@babel/plugin-transform-class-static-block" "^7.24.4"
"@babel/plugin-transform-class-static-block" "^7.24.4"
"@babel/plugin-transform-classes" "^7.24.1"
"@babel/plugin-transform-computed-properties" "^7.24.1"
"@babel/plugin-transform-destructuring" "^7.24.1"
Expand Down Expand Up @@ -1560,7 +1565,7 @@
resolved "https://registry.yarnpkg.com/@expo/sdk-runtime-versions/-/sdk-runtime-versions-1.0.0.tgz#d7ebd21b19f1c6b0395e50d78da4416941c57f7c"
integrity sha512-Doz2bfiPndXYFPMRwPyGa1k5QaKDVpY806UJj570epIiMzWaYyCtobasyfC++qfIXVb5Ocy7r3tP9d62hAQ7IQ==

"@expo/[email protected]":
"@expo/[email protected]", "@expo/spawn-async@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@expo/spawn-async/-/spawn-async-1.5.0.tgz#799827edd8c10ef07eb1a2ff9dcfe081d596a395"
integrity sha512-LB7jWkqrHo+5fJHNrLAFdimuSXQ2MQ4lA7SQW5bf/HbsXuV2VrT/jN/M8f/KoWt0uJMGN4k/j7Opx4AvOOxSew==
Expand Down Expand Up @@ -2876,7 +2881,7 @@
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==

"@urql/[email protected]":
"@urql/[email protected]", "@urql/core@>=2.3.1":
version "2.3.6"
resolved "https://registry.yarnpkg.com/@urql/core/-/core-2.3.6.tgz#ee0a6f8fde02251e9560c5f17dce5cd90f948552"
integrity sha512-PUxhtBh7/8167HJK6WqBv6Z0piuiaZHQGYbhwpNL9aIQmLROPEdaUYkY4wh45wPQXcTpnd11l0q3Pw+TI11pdw==
Expand Down Expand Up @@ -3223,7 +3228,7 @@ application-config-path@^0.1.0:
resolved "https://registry.yarnpkg.com/application-config-path/-/application-config-path-0.1.1.tgz#8b5ac64ff6afdd9bd70ce69f6f64b6998f5f756e"
integrity sha512-zy9cHePtMP0YhwG+CfHm0bgwdnga2X3gZexpdCwEj//dpb+TKajtiC8REEUJUSq6Ab4f9cgNy2l8ObXzCXFkEw==

[email protected]:
[email protected], arg@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0"
integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==
Expand Down Expand Up @@ -3475,7 +3480,7 @@ babel-plugin-jest-hoist@^29.6.3:

babel-plugin-module-resolver@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-5.0.0.tgz#2b7fc176bd55da25f516abf96015617b4f70fc73"
resolved "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-5.0.0.tgz"
integrity sha512-g0u+/ChLSJ5+PzYwLwP8Rp8Rcfowz58TJNCe+L/ui4rpzE/mg//JVX0EWBUYoxaextqnwuGHzfGp2hh0PPV25Q==
dependencies:
find-babel-config "^2.0.0"
Expand Down Expand Up @@ -5775,7 +5780,7 @@ fs.realpath@^1.0.0:

fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

function-bind@^1.1.2:
Expand Down Expand Up @@ -7405,7 +7410,7 @@ levn@^0.4.1:

[email protected]:
version "1.19.0"
resolved "https://registry.yarnpkg.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.19.0.tgz#56ab071e932f845dbb7667f44f5b78441175a343"
resolved "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.19.0.tgz"
integrity sha512-wIJmFtYX0rXHsXHSr4+sC5clwblEMji7HHQ4Ub1/CznVRxtCFha6JIt5JZaNf8vQrfdZnBxLLC6R8pC818jXqg==

[email protected]:
Expand Down Expand Up @@ -7441,6 +7446,7 @@ [email protected]:
[email protected]:
version "1.19.0"
resolved "https://registry.yarnpkg.com/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.19.0.tgz#0854dbd153035eca1396e2227c708ad43655a61c"
resolved "https://registry.yarnpkg.com/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.19.0.tgz#0854dbd153035eca1396e2227c708ad43655a61c"
integrity sha512-C+VuUTeSUOAaBZZOPT7Etn/agx/MatzJzGRkeV+zEABmPuntv1zihncsi+AyGmjkkzq3wVedEy7h0/4S84mUtg==

lightningcss@~1.19.0:
Expand Down Expand Up @@ -8277,7 +8283,7 @@ minipass-pipeline@^1.2.2:
dependencies:
minipass "^3.0.0"

[email protected]:
[email protected], minipass@^3.0.0, minipass@^3.1.1:
version "3.1.6"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.6.tgz#3b8150aa688a711a1521af5e8779c1d3bb4f45ee"
integrity sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==
Expand Down Expand Up @@ -8326,12 +8332,12 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==

[email protected]:
[email protected], ms@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

[email protected], ms@^2.1.1:
[email protected]:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
Expand Down Expand Up @@ -9893,12 +9899,12 @@ safe-array-concat@^1.1.2:
has-symbols "^1.0.3"
isarray "^2.0.5"

[email protected], safe-buffer@~5.1.0, safe-buffer@~5.1.1:
[email protected], safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==

[email protected], safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.2.0:
[email protected]:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
Expand Down

0 comments on commit a19f559

Please sign in to comment.