forked from 99x/first-born
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
99x#24 : migrating utilities to ts. defining seperate dir for types
- Loading branch information
1 parent
1b355bc
commit c9b3d7c
Showing
12 changed files
with
148 additions
and
81 deletions.
There are no files selected for viewing
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Type declarations | ||
* Before introducing a new type, please check for existing types in the list. | ||
*/ | ||
|
||
/** | ||
* Resulting object shape of the size calulation | ||
*/ | ||
export interface SizeStringsTypes { | ||
small: number; | ||
default: number; | ||
large: number; | ||
} | ||
|
||
/** | ||
* Size of the button, fontSizes, buttonPadding, roundRadius, iconSize are | ||
* picked from predefined sizes small, default and large. | ||
*/ | ||
export type SizeShapeTypes = "small" | "default" | "large"; | ||
|
||
/** | ||
* Resulting object shape for default font identifiers | ||
*/ | ||
export interface FontSizeObjTypes { | ||
h1: number; | ||
h2: number; | ||
h3: number; | ||
h4: number; | ||
h5: number; | ||
h6: number; | ||
p: number; | ||
callout: number; | ||
sub_heading: number; | ||
footnote: number; | ||
caption_big: number; | ||
caption_small: number; | ||
} | ||
|
||
/** | ||
* Acceptable font size text identifier. | ||
*/ | ||
export type FontTypes = | ||
| "h1" | ||
| "h2" | ||
| "h3" | ||
| "h4" | ||
| "h5" | ||
| "h6" | ||
| "p" | ||
| "callout" | ||
| "sub_heading" | ||
| "footnote" | ||
| "caption_big" | ||
| "caption_small"; | ||
|
||
/** | ||
* Shape and types of the mobile device screen information. | ||
*/ | ||
export interface DeviceVariables { | ||
width: number; | ||
height: number; | ||
Inset: { | ||
portrait: { | ||
topInset: number; | ||
leftInset: number; | ||
rightInset: number; | ||
bottomInset: number; | ||
}; | ||
landscape: { | ||
topInset: number; | ||
leftInset: number; | ||
rightInset: number; | ||
bottomInset: number; | ||
}; | ||
}; | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
import { SizeStringsTypes, SizeShapeTypes } from "../types"; | ||
|
||
const defaultFontSize: number = 16; | ||
const defaultButtonPadding: number = 10; | ||
const defaultRoundRadius: number = 20; | ||
const defaultIconSize: number = 20; | ||
|
||
const fontSizes: SizeStringsTypes = { | ||
small: defaultFontSize * 0.8, | ||
default: defaultFontSize, | ||
large: defaultFontSize * 1.3 | ||
}; | ||
|
||
const buttonPadding: SizeStringsTypes = { | ||
small: defaultButtonPadding * 0.8, | ||
default: defaultButtonPadding, | ||
large: defaultButtonPadding * 1.3 | ||
}; | ||
|
||
const roundRadius: SizeStringsTypes = { | ||
small: defaultRoundRadius * 0.8, | ||
default: defaultRoundRadius, | ||
large: defaultRoundRadius * 1.3 | ||
}; | ||
|
||
const iconSize: SizeStringsTypes = { | ||
small: defaultIconSize * 0.8, | ||
default: defaultIconSize, | ||
large: defaultIconSize * 1.3 | ||
}; | ||
|
||
export function getFontSize(size: SizeShapeTypes) { | ||
return fontSizes[size]; | ||
} | ||
|
||
export function getButtonPadding(size: SizeShapeTypes) { | ||
return buttonPadding[size]; | ||
} | ||
export function getRoundRadius(size: SizeShapeTypes) { | ||
return roundRadius[size]; | ||
} | ||
|
||
export function getIconSize(size: SizeShapeTypes) { | ||
return iconSize[size]; | ||
} |
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