@os-design/styles 1.0.44 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@os-design/styles",
3
- "version": "1.0.44",
3
+ "version": "1.0.45",
4
4
  "license": "UNLICENSED",
5
5
  "repository": "git@gitlab.com:os-team/libs/os-design.git",
6
6
  "main": "dist/cjs/index.js",
@@ -14,7 +14,15 @@
14
14
  "./package.json": "./package.json"
15
15
  },
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "src",
19
+ "!**/*.test.ts",
20
+ "!**/*.test.tsx",
21
+ "!**/__tests__",
22
+ "!**/*.stories.tsx",
23
+ "!**/*.stories.mdx",
24
+ "!**/*.example.tsx",
25
+ "!**/*.emotion.d.ts"
18
26
  ],
19
27
  "sideEffects": false,
20
28
  "scripts": {
@@ -29,18 +37,18 @@
29
37
  "access": "public"
30
38
  },
31
39
  "dependencies": {
32
- "@os-design/media": "^1.0.18",
33
- "@os-design/theming": "^1.0.42",
40
+ "@os-design/media": "^1.0.19",
41
+ "@os-design/theming": "^1.0.43",
34
42
  "facepaint": "^1.2.1"
35
43
  },
36
44
  "devDependencies": {
37
45
  "@emotion/react": ">=11",
38
46
  "@emotion/serialize": "*",
39
- "@os-design/omit-emotion-props": "^1.0.11"
47
+ "@os-design/omit-emotion-props": "^1.0.12"
40
48
  },
41
49
  "peerDependencies": {
42
50
  "@emotion/react": ">=11",
43
51
  "@emotion/serialize": "*"
44
52
  },
45
- "gitHead": "0e88d3afc41e36cee61222a039ef1aa4d08115b5"
53
+ "gitHead": "3d6b264027712ef81a75379fe3fde3c76c3079af"
46
54
  }
@@ -0,0 +1,7 @@
1
+ import '@emotion/react';
2
+ import { Theme as BaseTheme } from '@os-design/theming';
3
+
4
+ declare module '@emotion/react' {
5
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
6
+ export interface Theme extends BaseTheme {}
7
+ }
@@ -0,0 +1,9 @@
1
+ import { css } from '@emotion/react';
2
+
3
+ const ellipsisStyles = css`
4
+ white-space: nowrap;
5
+ overflow: hidden;
6
+ text-overflow: ellipsis;
7
+ `;
8
+
9
+ export default ellipsisStyles;
@@ -0,0 +1,28 @@
1
+ import { css } from '@emotion/react';
2
+ import { SerializedStyles } from '@emotion/serialize';
3
+
4
+ const enableScrollingStyles = (
5
+ axis: 'x' | 'y' | 'both',
6
+ showScrollbar = true
7
+ ): SerializedStyles => css`
8
+ ${['x', 'both'].includes(axis) &&
9
+ css`
10
+ overflow-x: auto;
11
+ `};
12
+
13
+ ${['y', 'both'].includes(axis) &&
14
+ css`
15
+ overflow-y: auto;
16
+ `};
17
+
18
+ ${!showScrollbar &&
19
+ css`
20
+ ::-webkit-scrollbar {
21
+ display: none;
22
+ }
23
+ `};
24
+
25
+ -webkit-overflow-scrolling: touch;
26
+ `;
27
+
28
+ export default enableScrollingStyles;
@@ -0,0 +1,19 @@
1
+ import { m } from '@os-design/media';
2
+ import fp from 'facepaint';
3
+
4
+ type Side = 'left' | 'right' | 'both';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
7
+ const horizontalPaddingStyles =
8
+ (side: Side = 'both') =>
9
+ (p) =>
10
+ fp([m.min.sm])({
11
+ paddingLeft: ['left', 'both'].includes(side)
12
+ ? p.theme.horizontalPadding.map((v) => `${v}em`)
13
+ : undefined,
14
+ paddingRight: ['right', 'both'].includes(side)
15
+ ? p.theme.horizontalPadding.map((v) => `${v}em`)
16
+ : undefined,
17
+ });
18
+
19
+ export default horizontalPaddingStyles;
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ export { default as ellipsisStyles } from './ellipsisStyles';
2
+ export { default as enableScrollingStyles } from './enableScrollingStyles';
3
+ export { default as horizontalPaddingStyles } from './horizontalPaddingStyles';
4
+ export { default as lineClampStyles } from './lineClampStyles';
5
+ export { default as resetButtonStyles } from './resetButtonStyles';
6
+ export { default as resetFocusStyles } from './resetFocusStyles';
7
+ export { default as resetUlStyles } from './resetUlStyles';
8
+ export { default as sizeStyles } from './sizeStyles';
9
+ export { default as transitionStyles } from './transitionStyles';
10
+
11
+ export * from './sizeStyles';
@@ -0,0 +1,11 @@
1
+ import { css } from '@emotion/react';
2
+ import { SerializedStyles } from '@emotion/serialize';
3
+
4
+ const lineClampStyles = (maxLines: number): SerializedStyles => css`
5
+ display: -webkit-box;
6
+ -webkit-line-clamp: ${maxLines};
7
+ -webkit-box-orient: vertical;
8
+ overflow: hidden;
9
+ `;
10
+
11
+ export default lineClampStyles;
@@ -0,0 +1,10 @@
1
+ import { css } from '@emotion/react';
2
+ import resetFocusStyles from '../resetFocusStyles';
3
+
4
+ const resetButtonStyles = css`
5
+ ${resetFocusStyles};
6
+ border: 0;
7
+ padding: 0;
8
+ `;
9
+
10
+ export default resetButtonStyles;
@@ -0,0 +1,9 @@
1
+ import { css } from '@emotion/react';
2
+
3
+ const resetFocusStyles = css`
4
+ &:focus {
5
+ outline: none;
6
+ }
7
+ `;
8
+
9
+ export default resetFocusStyles;
@@ -0,0 +1,9 @@
1
+ import { css } from '@emotion/react';
2
+
3
+ const resetUlStyles = css`
4
+ list-style: none;
5
+ margin: 0;
6
+ padding: 0;
7
+ `;
8
+
9
+ export default resetUlStyles;
@@ -0,0 +1,25 @@
1
+ import { css } from '@emotion/react';
2
+ import { SerializedStyles } from '@emotion/serialize';
3
+
4
+ export interface WithSize {
5
+ /**
6
+ * The size of the element.
7
+ * @default medium
8
+ */
9
+ size?: 'small' | 'medium' | 'large' | string;
10
+ }
11
+
12
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
13
+ const sizeStyles = (p): SerializedStyles => {
14
+ const size = p.theme.sizes[p.size || 'medium'];
15
+ if (!size) {
16
+ return css`
17
+ font-size: ${p.size};
18
+ `;
19
+ }
20
+ return css`
21
+ font-size: ${size}em;
22
+ `;
23
+ };
24
+
25
+ export default sizeStyles;
@@ -0,0 +1,23 @@
1
+ import { css } from '@emotion/react';
2
+ import { SerializedStyles } from '@emotion/serialize';
3
+
4
+ const singleTransitionStyles = (property: string) => (p) =>
5
+ css`
6
+ transition: ${property} ${p.theme.transitionDelay}ms;
7
+ `;
8
+
9
+ const multipleTransitionsStyles = (properties: string[]) => (p) =>
10
+ css`
11
+ transition: all ${p.theme.transitionDelay}ms;
12
+ transition-property: ${properties.join(', ')};
13
+ `;
14
+
15
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
16
+ const transitionStyles =
17
+ (...props: string[]) =>
18
+ (p): SerializedStyles =>
19
+ props.length === 1
20
+ ? singleTransitionStyles(props[0])(p)
21
+ : multipleTransitionsStyles(props)(p);
22
+
23
+ export default transitionStyles;