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

[No QA] [TS migration] Migrate 'addOutlineWidth' style to TypeScript #25945

Merged
merged 2 commits into from
Aug 31, 2023
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
25 changes: 0 additions & 25 deletions src/styles/addOutlineWidth/index.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/styles/addOutlineWidth/index.native.js

This file was deleted.

10 changes: 10 additions & 0 deletions src/styles/addOutlineWidth/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Native platforms don't support the "addOutlineWidth" property, so this
* function is a no-op
*/

import AddOutlineWidth from './types';

const addOutlineWidth: AddOutlineWidth = (obj) => obj;

export default addOutlineWidth;
19 changes: 19 additions & 0 deletions src/styles/addOutlineWidth/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Web and desktop platforms support the "addOutlineWidth" property, so it
* can be added to the object
*/

import themeDefault from '../themes/default';
import AddOutlineWidth from './types';

/**
* Adds the addOutlineWidth property to an object to be used when styling
*/
const addOutlineWidth: AddOutlineWidth = (obj, val, error = false) => ({
...obj,
outlineWidth: val,
outlineStyle: val ? 'auto' : 'none',
boxShadow: val !== 0 ? `0px 0px 0px ${val}px ${error ? themeDefault.danger : themeDefault.borderFocus}` : 'none',
});

export default addOutlineWidth;
6 changes: 6 additions & 0 deletions src/styles/addOutlineWidth/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {CSSProperties} from 'react';
import {TextStyle} from 'react-native';

type AddOutlineWidth = (obj: TextStyle | CSSProperties, val?: number, error?: boolean) => TextStyle | CSSProperties;

export default AddOutlineWidth;