@ribbon-studios/ribbon 1.0.4 → 1.1.0
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/.github/workflows/ci.yml +2 -2
- package/__tests__/setup.ts +9 -0
- package/bun.lockb +0 -0
- package/demo/App.tsx +2 -3
- package/dist/demo/App.d.ts +1 -0
- package/dist/demo/index.d.ts +1 -0
- package/dist/index.cjs +50 -0
- package/dist/index.css +1 -55
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1506 -67
- package/dist/src/Ribbon.d.ts +31 -0
- package/dist/src/__tests__/index.spec.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/eslint.config.ts +14 -0
- package/flake.lock +3 -3
- package/package.json +31 -31
- package/src/Ribbon.tsx +41 -38
- package/src/__tests__/index.spec.tsx +19 -6
- package/{global.d.ts → src/global.d.ts} +1 -1
- package/tsconfig.json +1 -1
- package/vite.config.ts +50 -0
- package/.eslintrc +0 -15
- package/__tests__/identity-obj-proxy-esm.ts +0 -13
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/module.js +0 -58
- package/dist/module.js.map +0 -1
- package/dist/types.d.ts +0 -28
- package/dist/types.d.ts.map +0 -1
- package/jest.config.ts +0 -30
- /package/src/{Ribbon.module.scss → Ribbon.module.css} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ComponentProps, ElementType, ReactNode } from 'react';
|
|
2
|
+
export declare function Ribbon<T extends ElementType = 'div'>({ as, children, backgroundColor, color, position, ...props }: Ribbon.Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace Ribbon {
|
|
4
|
+
type Props<T extends ElementType<{
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
}>> = {
|
|
7
|
+
as?: T;
|
|
8
|
+
/**
|
|
9
|
+
* The contents of the ribbon
|
|
10
|
+
*/
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* The font color
|
|
14
|
+
*
|
|
15
|
+
* @default 'black'
|
|
16
|
+
*/
|
|
17
|
+
color?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The background color
|
|
20
|
+
*
|
|
21
|
+
* @default 'white'
|
|
22
|
+
*/
|
|
23
|
+
backgroundColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the ribbon should be aligned at the 'top' or 'bottom'
|
|
26
|
+
*
|
|
27
|
+
* @default 'top-right'
|
|
28
|
+
*/
|
|
29
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
30
|
+
} & ComponentProps<T>;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Ribbon';
|
package/eslint.config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
import unusedImports from 'eslint-plugin-unused-imports';
|
|
4
|
+
|
|
5
|
+
export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended, {
|
|
6
|
+
plugins: {
|
|
7
|
+
'unused-imports': unusedImports,
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
'@typescript-eslint/no-namespace': 'off',
|
|
11
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
12
|
+
'unused-imports/no-unused-imports': 'error',
|
|
13
|
+
},
|
|
14
|
+
});
|
package/flake.lock
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"nodes": {
|
|
3
3
|
"nixpkgs": {
|
|
4
4
|
"locked": {
|
|
5
|
-
"lastModified":
|
|
6
|
-
"narHash": "sha256-
|
|
5
|
+
"lastModified": 1741173522,
|
|
6
|
+
"narHash": "sha256-k7VSqvv0r1r53nUI/IfPHCppkUAddeXn843YlAC5DR0=",
|
|
7
7
|
"owner": "NixOS",
|
|
8
8
|
"repo": "nixpkgs",
|
|
9
|
-
"rev": "
|
|
9
|
+
"rev": "d69ab0d71b22fa1ce3dbeff666e6deb4917db049",
|
|
10
10
|
"type": "github"
|
|
11
11
|
},
|
|
12
12
|
"original": {
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ribbon-studios/ribbon",
|
|
3
3
|
"description": "A simple react ribbon~",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"source": "src/index.ts",
|
|
6
|
-
"main": "dist/index.
|
|
7
|
-
"module": "dist/
|
|
8
|
-
"types": "dist/
|
|
7
|
+
"main": "dist/index.cjs",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
9
10
|
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
"build": "
|
|
11
|
+
"dev": "vite dev",
|
|
12
|
+
"build": "vite build",
|
|
12
13
|
"lint": "eslint .",
|
|
13
|
-
"test": "
|
|
14
|
-
"test:coverage": "
|
|
14
|
+
"test": "vitest",
|
|
15
|
+
"test:coverage": "vitest --coverage"
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {
|
|
17
18
|
"react": "*"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@parcel/transformer-typescript-types": "2.11.0",
|
|
25
|
-
"@testing-library/react": "^14.1.2",
|
|
21
|
+
"@eslint/js": "^9.24.0",
|
|
22
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
23
|
+
"@testing-library/react": "^16.3.0",
|
|
24
|
+
"@types/bun": "^1.2.8",
|
|
26
25
|
"@types/chance": "^1.1.6",
|
|
27
|
-
"@types/
|
|
28
|
-
"@types/react": "^
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"chance": "^1.1.
|
|
33
|
-
"eslint": "^
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
26
|
+
"@types/react": "^19.1.0",
|
|
27
|
+
"@types/react-dom": "^19.1.1",
|
|
28
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
29
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
30
|
+
"ajv": "^8.17.1",
|
|
31
|
+
"chance": "^1.1.12",
|
|
32
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
33
|
+
"happy-dom": "^17.4.4",
|
|
34
|
+
"jiti": "^2.4.2",
|
|
35
|
+
"react": "^19.1.0",
|
|
36
|
+
"react-dom": "^19.1.0",
|
|
37
|
+
"sass-embedded": "^1.86.3",
|
|
38
|
+
"typescript": "^5.8.2",
|
|
39
|
+
"typescript-eslint": "^8.29.0",
|
|
40
|
+
"vite": "^6.2.5",
|
|
41
|
+
"vite-plugin-dts": "^4.5.3",
|
|
42
|
+
"vite-plugin-lib-inject-css": "^2.2.1",
|
|
43
|
+
"vitest": "^3.1.1"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
package/src/Ribbon.tsx
CHANGED
|
@@ -1,51 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ComponentProps, ElementType, ReactNode } from 'react';
|
|
2
|
+
import styles from './Ribbon.module.css';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type RibbonProps = {
|
|
8
|
-
/**
|
|
9
|
-
* The contents of the ribbon
|
|
10
|
-
*/
|
|
11
|
-
children?: ReactNode;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The font color
|
|
15
|
-
*
|
|
16
|
-
* @default 'black'
|
|
17
|
-
*/
|
|
18
|
-
color?: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The background color
|
|
22
|
-
*
|
|
23
|
-
* @default 'white'
|
|
24
|
-
*/
|
|
25
|
-
backgroundColor?: string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Whether the ribbon should be aligned at the 'top' or 'bottom'
|
|
29
|
-
*
|
|
30
|
-
* @default 'top-right'
|
|
31
|
-
*/
|
|
32
|
-
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
33
|
-
} & Pick<ComponentProps<'div'>, 'onClick'>;
|
|
34
|
-
|
|
35
|
-
export function Ribbon({
|
|
4
|
+
export function Ribbon<T extends ElementType = 'div'>({
|
|
5
|
+
as,
|
|
36
6
|
children,
|
|
37
7
|
backgroundColor = 'white',
|
|
38
8
|
color = 'black',
|
|
39
9
|
position = 'top-right',
|
|
40
10
|
...props
|
|
41
|
-
}:
|
|
11
|
+
}: Ribbon.Props<T>) {
|
|
12
|
+
const Component = as ?? 'div';
|
|
42
13
|
const [vertical, horizontal] = position.split('-');
|
|
43
14
|
|
|
44
15
|
return (
|
|
45
|
-
<div
|
|
46
|
-
<
|
|
16
|
+
<div className={`${styles.ribbon} ${styles[vertical]} ${styles[horizontal]}`} data-testid="ribbon">
|
|
17
|
+
<Component {...props} className={styles.content} style={{ backgroundColor, color }} data-testid="ribbon-content">
|
|
47
18
|
{children}
|
|
48
|
-
</
|
|
19
|
+
</Component>
|
|
49
20
|
</div>
|
|
50
21
|
);
|
|
51
22
|
}
|
|
23
|
+
|
|
24
|
+
export namespace Ribbon {
|
|
25
|
+
export type Props<T extends ElementType<{ onClick?: () => void }>> = {
|
|
26
|
+
as?: T;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The contents of the ribbon
|
|
30
|
+
*/
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The font color
|
|
35
|
+
*
|
|
36
|
+
* @default 'black'
|
|
37
|
+
*/
|
|
38
|
+
color?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The background color
|
|
42
|
+
*
|
|
43
|
+
* @default 'white'
|
|
44
|
+
*/
|
|
45
|
+
backgroundColor?: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Whether the ribbon should be aligned at the 'top' or 'bottom'
|
|
49
|
+
*
|
|
50
|
+
* @default 'top-right'
|
|
51
|
+
*/
|
|
52
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
53
|
+
} & ComponentProps<T>;
|
|
54
|
+
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
2
|
-
/// <reference path="../../global.d.ts" />
|
|
3
|
-
|
|
4
1
|
import { render } from '@testing-library/react';
|
|
5
2
|
import { Chance } from 'chance';
|
|
6
|
-
import { Ribbon
|
|
7
|
-
import
|
|
3
|
+
import { Ribbon } from '../';
|
|
4
|
+
import styles from '../Ribbon.module.css';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
8
6
|
|
|
9
7
|
const chance = new Chance();
|
|
10
8
|
|
|
@@ -60,7 +58,7 @@ describe('component(Ribbon)', () => {
|
|
|
60
58
|
expect(component.getByTestId('ribbon').classList).toContain(styles.right);
|
|
61
59
|
});
|
|
62
60
|
|
|
63
|
-
const positions: NonNullable<
|
|
61
|
+
const positions: NonNullable<Ribbon.Props<'div'>['position']>[] = ['top-left', 'bottom-right', 'bottom-left'];
|
|
64
62
|
for (const position of positions) {
|
|
65
63
|
it(`should support '${position}'`, () => {
|
|
66
64
|
const [v, h] = position.split('-');
|
|
@@ -72,4 +70,19 @@ describe('component(Ribbon)', () => {
|
|
|
72
70
|
});
|
|
73
71
|
}
|
|
74
72
|
});
|
|
73
|
+
|
|
74
|
+
describe('prop(as)', () => {
|
|
75
|
+
it('should default to a div', () => {
|
|
76
|
+
const component = render(<Ribbon />);
|
|
77
|
+
|
|
78
|
+
expect(component.getByTestId('ribbon-content').tagName).toEqual('DIV');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should support other types', () => {
|
|
82
|
+
const component = render(<Ribbon as="a" href="https://tyria.ribbonstudios.com" />);
|
|
83
|
+
|
|
84
|
+
expect(component.getByTestId('ribbon-content').tagName).toEqual('A');
|
|
85
|
+
expect(component.getByTestId('ribbon-content').getAttribute('href')).toEqual('https://tyria.ribbonstudios.com');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
75
88
|
});
|
package/tsconfig.json
CHANGED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import react from '@vitejs/plugin-react';
|
|
2
|
+
import { libInjectCss } from 'vite-plugin-lib-inject-css';
|
|
3
|
+
import { dirname, resolve } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { defineConfig } from 'vite';
|
|
6
|
+
import dts from 'vite-plugin-dts';
|
|
7
|
+
import { peerDependencies } from './package.json';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
// https://vitejs.dev/config/
|
|
12
|
+
export default defineConfig(({ command }) => ({
|
|
13
|
+
build: {
|
|
14
|
+
lib: command === 'build' && {
|
|
15
|
+
entry: [resolve(__dirname, './src/index.ts')],
|
|
16
|
+
formats: ['es', 'cjs'],
|
|
17
|
+
},
|
|
18
|
+
rollupOptions:
|
|
19
|
+
command === 'serve'
|
|
20
|
+
? {
|
|
21
|
+
input: {
|
|
22
|
+
index: resolve(__dirname, './demo/index.html'),
|
|
23
|
+
},
|
|
24
|
+
external: Object.keys(peerDependencies),
|
|
25
|
+
}
|
|
26
|
+
: undefined,
|
|
27
|
+
},
|
|
28
|
+
resolve: {
|
|
29
|
+
alias: {
|
|
30
|
+
'@': resolve(__dirname, './src'),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
test: {
|
|
34
|
+
environment: 'happy-dom',
|
|
35
|
+
setupFiles: './__tests__/setup.ts',
|
|
36
|
+
include: ['./src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
37
|
+
coverage: {
|
|
38
|
+
reporter: ['text', 'lcovonly'],
|
|
39
|
+
include: ['src/**/*.{ts,tsx}'],
|
|
40
|
+
exclude: ['/demo/', '**/dist/', '**/__tests__/'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
plugins: [
|
|
44
|
+
react(),
|
|
45
|
+
dts({
|
|
46
|
+
insertTypesEntry: true,
|
|
47
|
+
}),
|
|
48
|
+
libInjectCss(),
|
|
49
|
+
],
|
|
50
|
+
}));
|
package/.eslintrc
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parser": "@typescript-eslint/parser",
|
|
3
|
-
"extends": [
|
|
4
|
-
"eslint:recommended",
|
|
5
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
6
|
-
"plugin:@typescript-eslint/recommended"
|
|
7
|
-
],
|
|
8
|
-
"plugins": ["unused-imports", "@typescript-eslint"],
|
|
9
|
-
"rules": {
|
|
10
|
-
"@typescript-eslint/no-namespace": "off",
|
|
11
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
12
|
-
"unused-imports/no-unused-imports-ts": "error"
|
|
13
|
-
},
|
|
14
|
-
"ignorePatterns": ["**/node_modules/", "**/dist/", "*.d.ts"]
|
|
15
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// identity-obj-proxy has a bug when using scss files with the syntax '* as styles'
|
|
2
|
-
module.exports = new Proxy(
|
|
3
|
-
{},
|
|
4
|
-
{
|
|
5
|
-
get: function getter(target, key) {
|
|
6
|
-
if (key === '__esModule') {
|
|
7
|
-
// True instead of false to pretend we're an ES module.
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
return key;
|
|
11
|
-
},
|
|
12
|
-
}
|
|
13
|
-
);
|
package/dist/index.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;;;;;AAaA;;;;AAIA;;;;;;;;;;;;;;;;AAgBA;;;;AAIA;;;;AAGA;;;;AAGA;;;;AAGA","sources":["src/Ribbon.module.scss"],"sourcesContent":[".ribbon {\n position: fixed;\n z-index: 9999;\n width: 80px;\n height: 80px;\n pointer-events: none;\n user-select: none;\n opacity: 1;\n transform: rotate(45deg);\n transition: opacity 0.15s ease-in-out;\n backface-visibility: hidden;\n}\n\n.ribbon:hover {\n opacity: 0.75;\n}\n\n.content {\n font: bold 15px Sans-Serif;\n text-align: center;\n position: relative;\n padding: 7px 0;\n width: 150px;\n box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3);\n pointer-events: all;\n text-transform: uppercase;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n background-color: #fafafa;\n color: #333;\n}\n\n.ribbon.bottom.right,\n.ribbon.top.left {\n transform: rotate(-45deg);\n}\n.ribbon.bottom {\n bottom: -10px;\n}\n.ribbon.top {\n top: -10px;\n}\n.ribbon.left {\n left: -10px;\n}\n.ribbon.right {\n right: -10px;\n}\n"],"names":[],"version":3,"file":"index.css.map"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,qEAAqE;AACrE,uCAAuC;;;;;;;;;;ACDvC,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAA2B,CAAC,aAAa,CAAC;AAC1C,4CAA4B,CAAC,cAAc,CAAC;AAC5C,4CAAyB,CAAC,WAAW,CAAC;AACtC,4CAA2B,CAAC,aAAa,CAAC;AAC1C,4CAA0B,CAAC,YAAY,CAAC;AACxC,0CAAwB,CAAC,UAAU,CAAC;;;AD6B7B,SAAS,0CAAO,YACrB,QAAQ,mBACR,kBAAkB,gBAClB,QAAQ,mBACR,WAAW,aACX,GAAG,OACS;IACZ,MAAM,CAAC,UAAU,WAAW,GAAG,SAAS,KAAK,CAAC;IAE9C,qBACE,gCAAC;QAAK,GAAG,KAAK;QAAE,WAAW,CAAC,EAAE,0BAAO,MAAM,CAAC,CAAC,EAAE,yBAAM,CAAC,SAAS,CAAC,CAAC,EAAE,yBAAM,CAAC,WAAW,CAAC,CAAC;QAAE,eAAY;kBACnG,cAAA,gCAAC;YAAI,WAAW,0BAAO,OAAO;YAAE,OAAO;iCAAE;uBAAiB;YAAM;YAAG,eAAY;sBAC5E;;;AAIT","sources":["src/index.ts","src/Ribbon.tsx","src/Ribbon.module.scss"],"sourcesContent":["export * from './Ribbon';\n","// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../global.d.ts\" />\n\nimport { ComponentProps, ReactNode } from 'react';\nimport * as styles from './Ribbon.module.scss';\n\nexport type RibbonProps = {\n /**\n * The contents of the ribbon\n */\n children?: ReactNode;\n\n /**\n * The font color\n *\n * @default 'black'\n */\n color?: string;\n\n /**\n * The background color\n *\n * @default 'white'\n */\n backgroundColor?: string;\n\n /**\n * Whether the ribbon should be aligned at the 'top' or 'bottom'\n *\n * @default 'top-right'\n */\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';\n} & Pick<ComponentProps<'div'>, 'onClick'>;\n\nexport function Ribbon({\n children,\n backgroundColor = 'white',\n color = 'black',\n position = 'top-right',\n ...props\n}: RibbonProps) {\n const [vertical, horizontal] = position.split('-');\n\n return (\n <div {...props} className={`${styles.ribbon} ${styles[vertical]} ${styles[horizontal]}`} data-testid=\"ribbon\">\n <div className={styles.content} style={{ backgroundColor, color }} data-testid=\"ribbon-content\">\n {children}\n </div>\n </div>\n );\n}\n",".ribbon {\n position: fixed;\n z-index: 9999;\n width: 80px;\n height: 80px;\n pointer-events: none;\n user-select: none;\n opacity: 1;\n transform: rotate(45deg);\n transition: opacity 0.15s ease-in-out;\n backface-visibility: hidden;\n}\n\n.ribbon:hover {\n opacity: 0.75;\n}\n\n.content {\n font: bold 15px Sans-Serif;\n text-align: center;\n position: relative;\n padding: 7px 0;\n width: 150px;\n box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3);\n pointer-events: all;\n text-transform: uppercase;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n background-color: #fafafa;\n color: #333;\n}\n\n.ribbon.bottom.right,\n.ribbon.top.left {\n transform: rotate(-45deg);\n}\n.ribbon.bottom {\n bottom: -10px;\n}\n.ribbon.top {\n top: -10px;\n}\n.ribbon.left {\n left: -10px;\n}\n.ribbon.right {\n right: -10px;\n}\n"],"names":[],"version":3,"file":"index.js.map"}
|
package/dist/module.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
import {jsx as $lkOeU$jsx} from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function $parcel$export(e, n, v, s) {
|
|
6
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
-
}
|
|
8
|
-
var $05af965021a88cfe$exports = {};
|
|
9
|
-
|
|
10
|
-
$parcel$export($05af965021a88cfe$exports, "Ribbon", function () { return $05af965021a88cfe$export$6acf8bfe08d451ac; });
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
12
|
-
/// <reference path="../global.d.ts" />
|
|
13
|
-
|
|
14
|
-
var $ba41f8ebd12a42a2$exports = {};
|
|
15
|
-
|
|
16
|
-
$parcel$export($ba41f8ebd12a42a2$exports, "bottom", function () { return $ba41f8ebd12a42a2$export$40e543e69a8b3fbb; }, function (v) { return $ba41f8ebd12a42a2$export$40e543e69a8b3fbb = v; });
|
|
17
|
-
$parcel$export($ba41f8ebd12a42a2$exports, "content", function () { return $ba41f8ebd12a42a2$export$a7db06668cad9adb; }, function (v) { return $ba41f8ebd12a42a2$export$a7db06668cad9adb = v; });
|
|
18
|
-
$parcel$export($ba41f8ebd12a42a2$exports, "left", function () { return $ba41f8ebd12a42a2$export$eabcd2c8791e7bf4; }, function (v) { return $ba41f8ebd12a42a2$export$eabcd2c8791e7bf4 = v; });
|
|
19
|
-
$parcel$export($ba41f8ebd12a42a2$exports, "ribbon", function () { return $ba41f8ebd12a42a2$export$b463d277d30b81dc; }, function (v) { return $ba41f8ebd12a42a2$export$b463d277d30b81dc = v; });
|
|
20
|
-
$parcel$export($ba41f8ebd12a42a2$exports, "right", function () { return $ba41f8ebd12a42a2$export$79ffe56a765070d2; }, function (v) { return $ba41f8ebd12a42a2$export$79ffe56a765070d2 = v; });
|
|
21
|
-
$parcel$export($ba41f8ebd12a42a2$exports, "top", function () { return $ba41f8ebd12a42a2$export$1e95b668f3b82d; }, function (v) { return $ba41f8ebd12a42a2$export$1e95b668f3b82d = v; });
|
|
22
|
-
var $ba41f8ebd12a42a2$export$40e543e69a8b3fbb;
|
|
23
|
-
var $ba41f8ebd12a42a2$export$a7db06668cad9adb;
|
|
24
|
-
var $ba41f8ebd12a42a2$export$eabcd2c8791e7bf4;
|
|
25
|
-
var $ba41f8ebd12a42a2$export$b463d277d30b81dc;
|
|
26
|
-
var $ba41f8ebd12a42a2$export$79ffe56a765070d2;
|
|
27
|
-
var $ba41f8ebd12a42a2$export$1e95b668f3b82d;
|
|
28
|
-
$ba41f8ebd12a42a2$export$40e543e69a8b3fbb = `Z10rOW_bottom`;
|
|
29
|
-
$ba41f8ebd12a42a2$export$a7db06668cad9adb = `Z10rOW_content`;
|
|
30
|
-
$ba41f8ebd12a42a2$export$eabcd2c8791e7bf4 = `Z10rOW_left`;
|
|
31
|
-
$ba41f8ebd12a42a2$export$b463d277d30b81dc = `Z10rOW_ribbon`;
|
|
32
|
-
$ba41f8ebd12a42a2$export$79ffe56a765070d2 = `Z10rOW_right`;
|
|
33
|
-
$ba41f8ebd12a42a2$export$1e95b668f3b82d = `Z10rOW_top`;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function $05af965021a88cfe$export$6acf8bfe08d451ac({ children: children, backgroundColor: backgroundColor = "white", color: color = "black", position: position = "top-right", ...props }) {
|
|
37
|
-
const [vertical, horizontal] = position.split("-");
|
|
38
|
-
return /*#__PURE__*/ (0, $lkOeU$jsx)("div", {
|
|
39
|
-
...props,
|
|
40
|
-
className: `${$ba41f8ebd12a42a2$exports.ribbon} ${$ba41f8ebd12a42a2$exports[vertical]} ${$ba41f8ebd12a42a2$exports[horizontal]}`,
|
|
41
|
-
"data-testid": "ribbon",
|
|
42
|
-
children: /*#__PURE__*/ (0, $lkOeU$jsx)("div", {
|
|
43
|
-
className: $ba41f8ebd12a42a2$exports.content,
|
|
44
|
-
style: {
|
|
45
|
-
backgroundColor: backgroundColor,
|
|
46
|
-
color: color
|
|
47
|
-
},
|
|
48
|
-
"data-testid": "ribbon-content",
|
|
49
|
-
children: children
|
|
50
|
-
})
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export {$05af965021a88cfe$export$6acf8bfe08d451ac as Ribbon};
|
|
58
|
-
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;ACAA,qEAAqE;AACrE,uCAAuC;;;;;;;;;;ACDvC,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAA2B,CAAC,aAAa,CAAC;AAC1C,4CAA4B,CAAC,cAAc,CAAC;AAC5C,4CAAyB,CAAC,WAAW,CAAC;AACtC,4CAA2B,CAAC,aAAa,CAAC;AAC1C,4CAA0B,CAAC,YAAY,CAAC;AACxC,0CAAwB,CAAC,UAAU,CAAC;;;AD6B7B,SAAS,0CAAO,YACrB,QAAQ,mBACR,kBAAkB,gBAClB,QAAQ,mBACR,WAAW,aACX,GAAG,OACS;IACZ,MAAM,CAAC,UAAU,WAAW,GAAG,SAAS,KAAK,CAAC;IAE9C,qBACE,gBAAC;QAAK,GAAG,KAAK;QAAE,WAAW,CAAC,EAAE,0BAAO,MAAM,CAAC,CAAC,EAAE,yBAAM,CAAC,SAAS,CAAC,CAAC,EAAE,yBAAM,CAAC,WAAW,CAAC,CAAC;QAAE,eAAY;kBACnG,cAAA,gBAAC;YAAI,WAAW,0BAAO,OAAO;YAAE,OAAO;iCAAE;uBAAiB;YAAM;YAAG,eAAY;sBAC5E;;;AAIT","sources":["src/index.ts","src/Ribbon.tsx","src/Ribbon.module.scss"],"sourcesContent":["export * from './Ribbon';\n","// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../global.d.ts\" />\n\nimport { ComponentProps, ReactNode } from 'react';\nimport * as styles from './Ribbon.module.scss';\n\nexport type RibbonProps = {\n /**\n * The contents of the ribbon\n */\n children?: ReactNode;\n\n /**\n * The font color\n *\n * @default 'black'\n */\n color?: string;\n\n /**\n * The background color\n *\n * @default 'white'\n */\n backgroundColor?: string;\n\n /**\n * Whether the ribbon should be aligned at the 'top' or 'bottom'\n *\n * @default 'top-right'\n */\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';\n} & Pick<ComponentProps<'div'>, 'onClick'>;\n\nexport function Ribbon({\n children,\n backgroundColor = 'white',\n color = 'black',\n position = 'top-right',\n ...props\n}: RibbonProps) {\n const [vertical, horizontal] = position.split('-');\n\n return (\n <div {...props} className={`${styles.ribbon} ${styles[vertical]} ${styles[horizontal]}`} data-testid=\"ribbon\">\n <div className={styles.content} style={{ backgroundColor, color }} data-testid=\"ribbon-content\">\n {children}\n </div>\n </div>\n );\n}\n",".ribbon {\n position: fixed;\n z-index: 9999;\n width: 80px;\n height: 80px;\n pointer-events: none;\n user-select: none;\n opacity: 1;\n transform: rotate(45deg);\n transition: opacity 0.15s ease-in-out;\n backface-visibility: hidden;\n}\n\n.ribbon:hover {\n opacity: 0.75;\n}\n\n.content {\n font: bold 15px Sans-Serif;\n text-align: center;\n position: relative;\n padding: 7px 0;\n width: 150px;\n box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3);\n pointer-events: all;\n text-transform: uppercase;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n background-color: #fafafa;\n color: #333;\n}\n\n.ribbon.bottom.right,\n.ribbon.top.left {\n transform: rotate(-45deg);\n}\n.ribbon.bottom {\n bottom: -10px;\n}\n.ribbon.top {\n top: -10px;\n}\n.ribbon.left {\n left: -10px;\n}\n.ribbon.right {\n right: -10px;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ComponentProps, ReactNode } from "react";
|
|
2
|
-
export type RibbonProps = {
|
|
3
|
-
/**
|
|
4
|
-
* The contents of the ribbon
|
|
5
|
-
*/
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
/**
|
|
8
|
-
* The font color
|
|
9
|
-
*
|
|
10
|
-
* @default 'black'
|
|
11
|
-
*/
|
|
12
|
-
color?: string;
|
|
13
|
-
/**
|
|
14
|
-
* The background color
|
|
15
|
-
*
|
|
16
|
-
* @default 'white'
|
|
17
|
-
*/
|
|
18
|
-
backgroundColor?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Whether the ribbon should be aligned at the 'top' or 'bottom'
|
|
21
|
-
*
|
|
22
|
-
* @default 'top-right'
|
|
23
|
-
*/
|
|
24
|
-
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
25
|
-
} & Pick<ComponentProps<'div'>, 'onClick'>;
|
|
26
|
-
export function Ribbon({ children, backgroundColor, color, position, ...props }: RibbonProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";AAMA,0BAA0B;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,CAAC;CACtE,GAAG,IAAI,CAAC,eAAe,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;AAE3C,uBAAuB,EACrB,QAAQ,EACR,eAAyB,EACzB,KAAe,EACf,QAAsB,EACtB,GAAG,KAAK,EACT,EAAE,WAAW,2CAUb","sources":["src/src/Ribbon.tsx","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,"export * from './Ribbon';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/jest.config.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { JestConfigWithTsJest } from 'ts-jest';
|
|
2
|
-
|
|
3
|
-
const jestConfig: JestConfigWithTsJest = {
|
|
4
|
-
roots: ['<rootDir>/src'],
|
|
5
|
-
testEnvironment: 'jsdom',
|
|
6
|
-
|
|
7
|
-
moduleFileExtensions: ['js', 'mjs', 'cjs', 'jsx', 'ts', 'd.ts', 'tsx', 'json', 'node'],
|
|
8
|
-
|
|
9
|
-
transform: {
|
|
10
|
-
'^.+\\.tsx?$': [
|
|
11
|
-
'ts-jest',
|
|
12
|
-
{
|
|
13
|
-
tsconfig: 'tsconfig.json',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
coverageProvider: 'v8',
|
|
19
|
-
collectCoverageFrom: ['<rootDir>/src/**/*'],
|
|
20
|
-
|
|
21
|
-
coveragePathIgnorePatterns: ['__tests__'],
|
|
22
|
-
|
|
23
|
-
moduleNameMapper: {
|
|
24
|
-
'\\.(scss)$': '<rootDir>/__tests__/identity-obj-proxy-esm.ts',
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
transformIgnorePatterns: ['^.+\\.js$'],
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default jestConfig;
|
|
File without changes
|