decentraland-ui2 0.0.0-9008705175.commit-ca18515

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2019 Metaverse Holdings Ltd.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use files included in this repository except in compliance
5
+ with the License. You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ <img src="https://ui.decentraland.org/decentraland_256x256.png" height="128" width="128" />
2
+
3
+ # Decentraland UI v2
4
+
5
+ This is basically `Material UI` themed with Decentrland's look & feel + some of our own components
6
+
7
+ See: [ui2.decentraland.org](https://ui2.decentraland.org)
8
+
9
+ ## Usage
10
+
11
+ Install it:
12
+
13
+ ```bash
14
+ npm install --save decentraland-ui2
15
+ ```
16
+
17
+ ### Import Decentraland UI v2's theme styles in your App's entry point
18
+
19
+ In your main ReactDOM renderer import Theme Provider and the theme you want to use
20
+
21
+ ```tsx
22
+ // ./src/index.ts
23
+ ...
24
+ import { ThemeProvider } from '@mui/material/styles'
25
+ import { dark } from 'decentraland-ui2/lib/themes/theme'
26
+ ...
27
+
28
+ <ThemeProvider theme={dark}>
29
+ ...
30
+ </ThemeProvider>
31
+ ...
32
+ ```
33
+
34
+ Now you can use Decentraland UI v2's components:
35
+
36
+ ```tsx
37
+ import React from "react"
38
+ import { Button } from "decentraland-ui2/lib/@mui"
39
+
40
+ export const CustomButton = (props) => {
41
+ return <Button {...props}>Save</Button>
42
+ }
43
+ ```
44
+
45
+ ## Development
46
+
47
+ Prerequisites: Node.js 16 React 17|18 (or compatible)
48
+
49
+ Install dependencies and start Storybook:
50
+
51
+ ```
52
+ $ npm install
53
+ $ npm run generate:storybooks //This will regenerate @MUI components
54
+ $ npm run start
55
+ ```
@@ -0,0 +1,80 @@
1
+ export declare const neutral: {
2
+ white: string;
3
+ softWhite: string;
4
+ gray5: string;
5
+ gray4: string;
6
+ gray3: string;
7
+ gray2: string;
8
+ gray1: string;
9
+ gray0: string;
10
+ softBlack2: string;
11
+ softBlack1: string;
12
+ black: string;
13
+ };
14
+ export declare const textOnNeutral: typeof neutral;
15
+ export declare const base: {
16
+ primary: string;
17
+ primaryLight2: string;
18
+ primaryLight1: string;
19
+ primaryDark: string;
20
+ primaryAlt: string;
21
+ };
22
+ export declare const textOnBase: typeof base;
23
+ export declare const state: {
24
+ success: string;
25
+ successDark: string;
26
+ warning: string;
27
+ warningDark: string;
28
+ error: string;
29
+ errorDark: string;
30
+ };
31
+ export declare const textOnState: typeof state;
32
+ export declare const rarity: {
33
+ common: string;
34
+ uncommon: string;
35
+ rare: string;
36
+ epic: string;
37
+ legendary: string;
38
+ mythic: string;
39
+ unique: string;
40
+ };
41
+ export declare const rarityGradient: typeof rarity;
42
+ export declare const textOnRarity: typeof rarity;
43
+ export declare const brand: {
44
+ yellow: string;
45
+ melon: string;
46
+ orange: string;
47
+ ruby: string;
48
+ lavander: string;
49
+ voilet: string;
50
+ purpel: string;
51
+ };
52
+ export declare const textOnBrand: typeof brand;
53
+ export declare const gradient: {
54
+ flare: string;
55
+ cerise: string;
56
+ amin: string;
57
+ common: string;
58
+ uncommon: string;
59
+ rare: string;
60
+ epic: string;
61
+ legendary: string;
62
+ mythic: string;
63
+ unique: string;
64
+ };
65
+ export declare const textOnGradient: typeof gradient;
66
+ export declare const opacity: {
67
+ backdrop: number;
68
+ blurry: number;
69
+ soft: number;
70
+ subtle: number;
71
+ };
72
+ export declare const blackTransparent: {
73
+ backdrop: string;
74
+ blurry: string;
75
+ soft: string;
76
+ subtle: string;
77
+ };
78
+ export declare const textOnBlackTransparent: typeof blackTransparent;
79
+ export declare const whiteTransparent: typeof blackTransparent;
80
+ export declare const textOnWhiteTransparent: typeof blackTransparent;
package/dist/colors.js ADDED
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.textOnWhiteTransparent = exports.whiteTransparent = exports.textOnBlackTransparent = exports.blackTransparent = exports.opacity = exports.textOnGradient = exports.gradient = exports.textOnBrand = exports.brand = exports.textOnRarity = exports.rarityGradient = exports.rarity = exports.textOnState = exports.state = exports.textOnBase = exports.base = exports.textOnNeutral = exports.neutral = void 0;
4
+ exports.neutral = {
5
+ white: `#FFFFFF`,
6
+ softWhite: `#FCFCFC`,
7
+ gray5: `#ECEBED`,
8
+ gray4: `#CFCDD4`,
9
+ gray3: `#A09BA8`,
10
+ gray2: `#716B7C`,
11
+ gray1: `#5E5B67`,
12
+ gray0: `#43404A`,
13
+ softBlack2: `#242129`,
14
+ softBlack1: `#161518`,
15
+ black: `#000000`,
16
+ };
17
+ exports.textOnNeutral = {
18
+ white: exports.neutral.softBlack2,
19
+ softWhite: exports.neutral.softBlack2,
20
+ gray5: exports.neutral.softBlack2,
21
+ gray4: exports.neutral.softBlack2,
22
+ gray3: exports.neutral.white,
23
+ gray2: exports.neutral.white,
24
+ gray1: exports.neutral.white,
25
+ gray0: exports.neutral.white,
26
+ softBlack2: exports.neutral.white,
27
+ softBlack1: exports.neutral.white,
28
+ black: exports.neutral.white,
29
+ };
30
+ exports.base = {
31
+ primary: "#FF2D55",
32
+ primaryLight2: `#FFD8DF`,
33
+ primaryLight1: `#FFBFCB`,
34
+ primaryDark: `#DF1F43`,
35
+ primaryAlt: `#FF7439`,
36
+ };
37
+ exports.textOnBase = {
38
+ primary: exports.neutral.white,
39
+ primaryLight2: exports.neutral.black,
40
+ primaryLight1: exports.neutral.black,
41
+ primaryDark: exports.neutral.white,
42
+ primaryAlt: exports.neutral.white,
43
+ };
44
+ exports.state = {
45
+ success: `#34CE76`,
46
+ successDark: `#279E5A`,
47
+ warning: `#FFC95B`,
48
+ warningDark: `#E9AB2E`,
49
+ error: `#FB3B3B`,
50
+ errorDark: `#DA2828`,
51
+ };
52
+ exports.textOnState = {
53
+ success: exports.neutral.white,
54
+ successDark: exports.neutral.white,
55
+ warning: exports.neutral.softBlack2,
56
+ warningDark: exports.neutral.softBlack2,
57
+ error: exports.neutral.white,
58
+ errorDark: exports.neutral.white,
59
+ };
60
+ exports.rarity = {
61
+ common: `#73D3D3`,
62
+ uncommon: `#FF8362`,
63
+ rare: `#34CE76`,
64
+ epic: `#438FFF`,
65
+ legendary: `#A14BF3`,
66
+ mythic: `#FF4BED`,
67
+ unique: `#FEA217`,
68
+ };
69
+ const rarityLight = {
70
+ common: `#D2F9F9`,
71
+ uncommon: `#F9E4DF`,
72
+ rare: `#C1F2D6`,
73
+ epic: `#C0D3EF`,
74
+ legendary: `#E1C1FF`,
75
+ mythic: `#FDC4F7`,
76
+ unique: `#F3E5CF`,
77
+ };
78
+ exports.rarityGradient = {
79
+ common: `radial-gradient(circle, ${rarityLight.common} 0%, ${exports.rarity.common} 100%)`,
80
+ uncommon: `radial-gradient(circle, ${rarityLight.uncommon} 0%, ${exports.rarity.uncommon} 100%)`,
81
+ rare: `radial-gradient(circle, ${rarityLight.rare} 0%, ${exports.rarity.rare} 100%)`,
82
+ epic: `radial-gradient(circle, ${rarityLight.epic} 0%, ${exports.rarity.epic} 100%)`,
83
+ legendary: `radial-gradient(circle, ${rarityLight.legendary} 0%, ${exports.rarity.legendary} 100%)`,
84
+ mythic: `radial-gradient(circle, ${rarityLight.mythic} 0%, ${exports.rarity.mythic} 100%)`,
85
+ unique: `radial-gradient(circle, ${rarityLight.unique} 0%, ${exports.rarity.unique} 100%)`,
86
+ };
87
+ exports.textOnRarity = {
88
+ common: exports.neutral.white,
89
+ uncommon: exports.neutral.white,
90
+ rare: exports.neutral.white,
91
+ epic: exports.neutral.white,
92
+ legendary: exports.neutral.white,
93
+ mythic: exports.neutral.white,
94
+ unique: exports.neutral.white,
95
+ };
96
+ exports.brand = {
97
+ yellow: `#FFBC5B`,
98
+ melon: `#FFA25A`,
99
+ orange: `#FF7439`,
100
+ ruby: `#FF2D55`,
101
+ lavander: `#C640CD`,
102
+ voilet: `#A524B3`,
103
+ purpel: `#691FA9`,
104
+ };
105
+ exports.textOnBrand = {
106
+ yellow: exports.neutral.softBlack2,
107
+ melon: exports.neutral.softBlack2,
108
+ orange: exports.neutral.white,
109
+ ruby: exports.neutral.white,
110
+ lavander: exports.neutral.white,
111
+ voilet: exports.neutral.white,
112
+ purpel: exports.neutral.white,
113
+ };
114
+ exports.gradient = Object.assign(Object.assign({}, exports.rarityGradient), { flare: `linear-gradient(135deg, ${exports.brand.ruby} 0%, ${exports.brand.yellow} 100%)`, cerise: `linear-gradient(135deg, ${exports.brand.ruby} 0%, ${exports.brand.lavander} 100%)`, amin: `linear-gradient(135deg, ${exports.brand.lavander} 0%, ${exports.brand.purpel} 100%)` });
115
+ exports.textOnGradient = Object.assign(Object.assign({}, exports.textOnRarity), { flare: exports.neutral.white, cerise: exports.neutral.white, amin: exports.neutral.white });
116
+ exports.opacity = {
117
+ backdrop: 0.6,
118
+ blurry: 0.4,
119
+ soft: 0.2,
120
+ subtle: 0.1,
121
+ };
122
+ exports.blackTransparent = {
123
+ backdrop: `rgba(0, 0, 0, ${exports.opacity.backdrop})`,
124
+ blurry: `rgba(0, 0, 0, ${exports.opacity.blurry})`,
125
+ soft: `rgba(0, 0, 0, ${exports.opacity.soft})`,
126
+ subtle: `rgba(0, 0, 0, ${exports.opacity.subtle})`,
127
+ };
128
+ exports.textOnBlackTransparent = {
129
+ backdrop: exports.neutral.white,
130
+ blurry: exports.neutral.white,
131
+ soft: exports.neutral.black,
132
+ subtle: exports.neutral.black,
133
+ };
134
+ exports.whiteTransparent = {
135
+ backdrop: `rgba(255, 255, 255, ${exports.opacity.backdrop})`,
136
+ blurry: `rgba(255, 255, 255, ${exports.opacity.blurry})`,
137
+ soft: `rgba(255, 255, 255, ${exports.opacity.soft})`,
138
+ subtle: `rgba(255, 255, 255, ${exports.opacity.subtle})`,
139
+ };
140
+ exports.textOnWhiteTransparent = {
141
+ backdrop: exports.neutral.softBlack2,
142
+ blurry: exports.neutral.softBlack2,
143
+ soft: exports.neutral.softBlack2,
144
+ subtle: exports.neutral.softBlack2,
145
+ };
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { Coord, Layer, TileMapProps } from "react-tile-map";
3
+ import "react-tile-map/dist/styles.css";
4
+ export declare enum AtlasColor {
5
+ OWNED = "#3D3A46",
6
+ UNOWNED = "#09080A",
7
+ PLAZA = "#70AC76",
8
+ ROAD = "#716C7A",
9
+ DISTRICT = "#5054D4",
10
+ ODD = "#110E13",
11
+ EVEN = "#0D0B0E"
12
+ }
13
+ export declare enum AtlasTileType {
14
+ OWNED = "owned",
15
+ UNOWNED = "unowned",
16
+ PLAZA = "plaza",
17
+ ROAD = "road",
18
+ DISTRICT = "district"
19
+ }
20
+ export type AtlasTileProps = {
21
+ id?: string;
22
+ x: number;
23
+ y: number;
24
+ updatedAt: number;
25
+ type: AtlasTileType;
26
+ top?: boolean;
27
+ left?: boolean;
28
+ topLeft?: boolean;
29
+ name?: string;
30
+ estateId?: string;
31
+ owner: string;
32
+ tokenId?: string;
33
+ };
34
+ export { Layer, Coord };
35
+ export type AtlasProps = Omit<TileMapProps, "layers" | "className"> & {
36
+ layers?: Layer[];
37
+ tiles?: Record<string, AtlasTileProps>;
38
+ /** @deprecated */
39
+ className?: string;
40
+ };
41
+ export type AtlasStateProps = {
42
+ tiles?: Record<string, AtlasTileProps>;
43
+ };
44
+ export interface AtlasInterface extends AtlasProps {
45
+ }
46
+ export declare const Atlas: React.MemoExoticComponent<(props: AtlasProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Atlas = exports.AtlasTileType = exports.AtlasColor = void 0;
27
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ const react_tile_map_1 = require("react-tile-map");
30
+ const react_2 = require("@emotion/react");
31
+ const util_1 = require("./util");
32
+ const colors_1 = require("../../colors");
33
+ require("react-tile-map/dist/styles.css");
34
+ var AtlasColor;
35
+ (function (AtlasColor) {
36
+ AtlasColor["OWNED"] = "#3D3A46";
37
+ AtlasColor["UNOWNED"] = "#09080A";
38
+ AtlasColor["PLAZA"] = "#70AC76";
39
+ AtlasColor["ROAD"] = "#716C7A";
40
+ AtlasColor["DISTRICT"] = "#5054D4";
41
+ AtlasColor["ODD"] = "#110E13";
42
+ AtlasColor["EVEN"] = "#0D0B0E";
43
+ })(AtlasColor || (exports.AtlasColor = AtlasColor = {}));
44
+ var AtlasTileType;
45
+ (function (AtlasTileType) {
46
+ AtlasTileType["OWNED"] = "owned";
47
+ AtlasTileType["UNOWNED"] = "unowned";
48
+ AtlasTileType["PLAZA"] = "plaza";
49
+ AtlasTileType["ROAD"] = "road";
50
+ AtlasTileType["DISTRICT"] = "district";
51
+ })(AtlasTileType || (exports.AtlasTileType = AtlasTileType = {}));
52
+ exports.Atlas = react_1.default.memo((props) => {
53
+ const { layers } = props;
54
+ const [tiles, setTiles] = (0, react_1.useState)(props.tiles);
55
+ const mountedRef = react_1.default.useRef(true);
56
+ const layer = (0, react_1.useCallback)((x, y) => {
57
+ const id = x + "," + y;
58
+ if (tiles && id in tiles) {
59
+ const tile = tiles[id];
60
+ return {
61
+ color: (0, util_1.getColorByType)(tile.type),
62
+ top: tile.top,
63
+ left: tile.left,
64
+ topLeft: tile.topLeft,
65
+ };
66
+ }
67
+ else {
68
+ return {
69
+ color: (x + y) % 2 === 0 ? AtlasColor.ODD : AtlasColor.EVEN,
70
+ };
71
+ }
72
+ }, [tiles]);
73
+ (0, react_1.useEffect)(() => {
74
+ if (!tiles) {
75
+ (0, util_1.getTiles)().then(handleUpdateTiles);
76
+ }
77
+ return () => {
78
+ mountedRef.current = false;
79
+ };
80
+ }, [tiles]);
81
+ (0, react_1.useEffect)(() => {
82
+ if (props.tiles && props.tiles !== tiles) {
83
+ setTiles(props.tiles);
84
+ }
85
+ }, [props.tiles]);
86
+ const handleUpdateTiles = (updatedTiles) => {
87
+ if (mountedRef.current) {
88
+ setTiles(updatedTiles);
89
+ }
90
+ };
91
+ const atlasStyle = (0, react_2.css)({
92
+ background: colors_1.neutral.softBlack1,
93
+ });
94
+ const layersMemo = (0, react_1.useMemo)(() => [layer, ...(layers || [])], [layer, layers]);
95
+ return ((0, jsx_runtime_1.jsx)(react_tile_map_1.TileMap, Object.assign({}, react_tile_map_1.TileMap.defaultProps, props, { css: atlasStyle, layers: layersMemo })));
96
+ });
@@ -0,0 +1,11 @@
1
+ import { AtlasProps } from "./Atlas";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ declare const meta: Meta<AtlasProps>;
4
+ export default meta;
5
+ type Story = StoryObj<AtlasProps>;
6
+ export declare const Uncontrolled: Story;
7
+ export declare const Controlled: Story;
8
+ export declare const ForSale: Story;
9
+ export declare const ClickToSelect: Story;
10
+ export declare const HoverToHighlight: Story;
11
+ export declare const WithZoomControl: Story;
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WithZoomControl = exports.HoverToHighlight = exports.ClickToSelect = exports.ForSale = exports.Controlled = exports.Uncontrolled = void 0;
16
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
17
+ const styled_1 = __importDefault(require("@emotion/styled"));
18
+ const blocks_1 = require("@storybook/blocks");
19
+ const Atlas_1 = require("./Atlas");
20
+ const util_1 = require("./util");
21
+ let tiles;
22
+ if (window) {
23
+ (0, util_1.getTiles)().then((_tiles) => (tiles = _tiles));
24
+ }
25
+ // For Sale
26
+ const forSaleLayer = (x, y) => {
27
+ const key = x + "," + y;
28
+ if (tiles && tiles[key] && "price" in tiles[key]) {
29
+ return { color: "#00d3ff" };
30
+ }
31
+ return null;
32
+ };
33
+ // Selection
34
+ let selected = [];
35
+ function isSelected(x, y) {
36
+ return selected.some((coord) => coord.x === x && coord.y === y);
37
+ }
38
+ const selectedStrokeLayer = (x, y) => {
39
+ return isSelected(x, y) ? { color: "#ff0044", scale: 1.4 } : null;
40
+ };
41
+ const selectedFillLayer = (x, y) => {
42
+ return isSelected(x, y) ? { color: "#ff9990", scale: 1.2 } : null;
43
+ };
44
+ const handleClick = (x, y) => {
45
+ console.log(x, y);
46
+ if (isSelected(x, y)) {
47
+ selected = selected.filter((coord) => coord.x !== x || coord.y !== y);
48
+ }
49
+ else {
50
+ selected.push({ x, y });
51
+ }
52
+ };
53
+ // Hover
54
+ let hover;
55
+ const isValid = () => {
56
+ if (!hover)
57
+ return false;
58
+ // only valid if it fits in central plaza
59
+ return hover.x >= -5 && hover.x <= 6 && hover.y >= -5 && hover.y <= 5;
60
+ };
61
+ const isHighlighted = (x, y) => {
62
+ if (!hover)
63
+ return false;
64
+ // only highlight a 10x10 area centered around hover coords
65
+ const radius = 5;
66
+ return (x > hover.x - radius &&
67
+ x < hover.x + radius &&
68
+ y > hover.y - radius &&
69
+ y < hover.y + radius);
70
+ };
71
+ const handleHover = (x, y) => {
72
+ hover = { x, y };
73
+ };
74
+ const hoverStrokeLayer = (x, y) => {
75
+ if (isHighlighted(x, y)) {
76
+ return {
77
+ color: isValid() ? "#44ff00" : "#ff0044",
78
+ scale: 1.5,
79
+ };
80
+ }
81
+ return null;
82
+ };
83
+ const hoverFillLayer = (x, y) => {
84
+ if (isHighlighted(x, y)) {
85
+ return {
86
+ color: isValid() ? "#99ff90" : "#ff9990",
87
+ scale: 1.2,
88
+ };
89
+ }
90
+ return null;
91
+ };
92
+ const AtlasContainer = styled_1.default.div({
93
+ width: "90vw",
94
+ height: "90vh",
95
+ backgroundColor: "black",
96
+ });
97
+ const meta = {
98
+ component: Atlas_1.Atlas,
99
+ title: "Decentraland UI/Atlas",
100
+ tags: ["autodocs"],
101
+ argTypes: {
102
+ layers: {
103
+ description: "layer to render on the map",
104
+ },
105
+ className: {
106
+ description: "custom class name",
107
+ },
108
+ x: {
109
+ description: "where to position the map in the X axis",
110
+ },
111
+ y: {
112
+ description: "where to position the map in the Y axis",
113
+ },
114
+ initialX: {
115
+ description: "where to initially position the map in the X axis",
116
+ },
117
+ initialY: {
118
+ description: "where to initially position the map in the Y axis",
119
+ },
120
+ size: {
121
+ description: "size of each parcel, i.e: size=5 makes each parcel of 5x5 pixels",
122
+ },
123
+ width: {
124
+ description: "width of the canvas in pixels",
125
+ },
126
+ height: {
127
+ description: "height of the canvas in pixels",
128
+ },
129
+ zoom: {
130
+ description: "zoom level of the map, this changes in the end the size on which parcels are rendered, i.e: size=10 and zoom=0.5 makes each parcel of 5x5 pixels",
131
+ },
132
+ minX: {
133
+ description: "min values for x(ie. the map boundaries)",
134
+ },
135
+ maxX: {
136
+ description: "max values for x(ie. the map boundaries)",
137
+ },
138
+ minY: {
139
+ description: "min values for y (ie. the map boundaries)",
140
+ },
141
+ maxY: {
142
+ description: "max values for y (ie. the map boundaries)",
143
+ },
144
+ minSize: {
145
+ description: "minimum size that parcels can take (after applying zoom)",
146
+ },
147
+ maxSize: {
148
+ description: "maximum size that parcels can take (after applying zoom)",
149
+ },
150
+ panX: {
151
+ description: "initial panning in the X axis, this changes the initial position of the map adding an offset to the prop `x`",
152
+ },
153
+ panY: {
154
+ description: "initial panning in the Y axis, this changes the initial position of the map adding an offset to the prop `y`",
155
+ },
156
+ isDraggable: {
157
+ description: "whether the map should be draggable or not",
158
+ },
159
+ padding: {
160
+ description: "amount of padding tiles",
161
+ },
162
+ withZoomControls: {
163
+ description: "whether the zoom controls should appear",
164
+ },
165
+ onMouseDown: {
166
+ description: "callbacks",
167
+ },
168
+ onMouseUp: {
169
+ description: "callbacks",
170
+ },
171
+ onClick: {
172
+ description: "callbacks",
173
+ },
174
+ onHover: {
175
+ description: " - ",
176
+ },
177
+ onPopup: { description: " - " },
178
+ onChange: { description: " - " },
179
+ onCenterChange: { description: " - " },
180
+ renderMap: {
181
+ description: "renderer",
182
+ },
183
+ },
184
+ parameters: {
185
+ docs: {
186
+ page: () => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(blocks_1.Title, {}), (0, jsx_runtime_1.jsx)(blocks_1.ArgTypes, {})] })),
187
+ },
188
+ layout: "centered",
189
+ canvas: true,
190
+ },
191
+ loaders: [
192
+ () => __awaiter(void 0, void 0, void 0, function* () {
193
+ return ({
194
+ tiles: yield (0, util_1.getTiles)(),
195
+ });
196
+ }),
197
+ ],
198
+ decorators: [
199
+ (Story) => ((0, jsx_runtime_1.jsx)(AtlasContainer, { children: (0, jsx_runtime_1.jsx)(Story, {}) })),
200
+ ],
201
+ render: (args, { loaded: { tiles } }) => (0, jsx_runtime_1.jsx)(Atlas_1.Atlas, Object.assign({}, args, { tiles: tiles })),
202
+ };
203
+ exports.default = meta;
204
+ exports.Uncontrolled = {
205
+ args: {},
206
+ loaders: [
207
+ () => __awaiter(void 0, void 0, void 0, function* () {
208
+ return ({
209
+ tiles: null,
210
+ });
211
+ }),
212
+ ],
213
+ };
214
+ exports.Controlled = {
215
+ args: {},
216
+ loaders: [
217
+ () => __awaiter(void 0, void 0, void 0, function* () {
218
+ return ({
219
+ tiles: yield (0, util_1.getTiles)(),
220
+ });
221
+ }),
222
+ ],
223
+ };
224
+ exports.ForSale = {
225
+ args: {
226
+ layers: [forSaleLayer],
227
+ },
228
+ loaders: [
229
+ () => __awaiter(void 0, void 0, void 0, function* () {
230
+ return ({
231
+ tiles: yield (0, util_1.getTiles)(),
232
+ });
233
+ }),
234
+ ],
235
+ };
236
+ exports.ClickToSelect = {
237
+ args: {
238
+ layers: [selectedStrokeLayer, selectedFillLayer],
239
+ onClick: handleClick,
240
+ },
241
+ loaders: [
242
+ () => __awaiter(void 0, void 0, void 0, function* () {
243
+ return ({
244
+ tiles: yield (0, util_1.getTiles)(),
245
+ });
246
+ }),
247
+ ],
248
+ };
249
+ exports.HoverToHighlight = {
250
+ args: {
251
+ layers: [hoverStrokeLayer, hoverFillLayer],
252
+ onHover: handleHover,
253
+ },
254
+ loaders: [
255
+ () => __awaiter(void 0, void 0, void 0, function* () {
256
+ return ({
257
+ tiles: yield (0, util_1.getTiles)(),
258
+ });
259
+ }),
260
+ ],
261
+ };
262
+ exports.WithZoomControl = {
263
+ args: {
264
+ layers: [hoverStrokeLayer, hoverFillLayer],
265
+ onHover: handleHover,
266
+ withZoomControls: true,
267
+ },
268
+ loaders: [
269
+ () => __awaiter(void 0, void 0, void 0, function* () {
270
+ return ({
271
+ tiles: yield (0, util_1.getTiles)(),
272
+ });
273
+ }),
274
+ ],
275
+ };
@@ -0,0 +1,3 @@
1
+ import { AtlasColor, AtlasTileProps, AtlasTileType } from "./Atlas";
2
+ export declare const getTiles: () => Promise<Record<string, AtlasTileProps>>;
3
+ export declare function getColorByType(type: AtlasTileType): AtlasColor.OWNED | AtlasColor.UNOWNED | AtlasColor.PLAZA | AtlasColor.ROAD | AtlasColor.DISTRICT;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getColorByType = exports.getTiles = void 0;
13
+ const radash_1 = require("radash");
14
+ const Atlas_1 = require("./Atlas");
15
+ const TILES_URL = "https://api.decentraland.org/v2/tiles";
16
+ exports.getTiles = (0, radash_1.memo)(() => __awaiter(void 0, void 0, void 0, function* () {
17
+ try {
18
+ const tilesFetch = yield fetch(TILES_URL);
19
+ const tilesJson = yield tilesFetch.json();
20
+ return tilesJson.data;
21
+ }
22
+ catch (error) {
23
+ return {};
24
+ }
25
+ }), { ttl: 10 * 60 * 1000 } // 10 minutes
26
+ );
27
+ function getColorByType(type) {
28
+ switch (type) {
29
+ case Atlas_1.AtlasTileType.OWNED:
30
+ return Atlas_1.AtlasColor.OWNED;
31
+ case Atlas_1.AtlasTileType.UNOWNED:
32
+ return Atlas_1.AtlasColor.UNOWNED;
33
+ case Atlas_1.AtlasTileType.PLAZA:
34
+ return Atlas_1.AtlasColor.PLAZA;
35
+ case Atlas_1.AtlasTileType.ROAD:
36
+ return Atlas_1.AtlasColor.ROAD;
37
+ case Atlas_1.AtlasTileType.DISTRICT:
38
+ return Atlas_1.AtlasColor.DISTRICT;
39
+ }
40
+ }
41
+ exports.getColorByType = getColorByType;
File without changes
@@ -0,0 +1,5 @@
1
+ describe("silly test", () => {
2
+ it("silly test", () => {
3
+ expect(true).toBe(true);
4
+ });
5
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "WEARABLE_PREVIEW_URL": "https://wearable-preview.decentraland.zone",
3
+ "ACCOUNT_URL": "https://account.decentraland.zone",
4
+ "PROFILE_URL": "https://profile.decentraland.zone",
5
+ "MARKETPLACE_URL": "https://market.decentraland.zone",
6
+ "BUILDER_URL": "https://builder.decentraland.zone",
7
+ "DAO_URL": "https://dao.decentraland.zone",
8
+ "GOVERNANCE_URL": "https://governance.decentraland.zone",
9
+ "EVENTS_URL": "https://events.decentraland.zone",
10
+ "PLACES_URL": "https://places.decentraland.zone"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "WEARABLE_PREVIEW_URL": "https://wearable-preview.decentraland.org",
3
+ "ACCOUNT_URL": "https://account.decentraland.org",
4
+ "PROFILE_URL": "https://profile.decentraland.org",
5
+ "MARKETPLACE_URL": "https://market.decentraland.org",
6
+ "BUILDER_URL": "https://builder.decentraland.org",
7
+ "DAO_URL": "https://dao.decentraland.org",
8
+ "GOVERNANCE_URL": "https://governance.decentraland.org",
9
+ "EVENTS_URL": "https://events.decentraland.org",
10
+ "PLACES_URL": "https://places.decentraland.org"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "WEARABLE_PREVIEW_URL": "https://wearable-preview.decentraland.today",
3
+ "ACCOUNT_URL": "https://account.decentraland.today",
4
+ "PROFILE_URL": "https://profile.decentraland.today",
5
+ "MARKETPLACE_URL": "https://market.decentraland.today",
6
+ "BUILDER_URL": "https://builder.decentraland.today",
7
+ "DAO_URL": "https://dao.decentraland.today",
8
+ "GOVERNANCE_URL": "https://governance.decentraland.today",
9
+ "EVENTS_URL": "https://events.decentraland.today",
10
+ "PLACES_URL": "https://places.decentraland.today"
11
+ }
@@ -0,0 +1 @@
1
+ export declare const config: import("@dcl/ui-env/dist/config").IConfig;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.config = void 0;
7
+ const ui_env_1 = require("@dcl/ui-env");
8
+ const dev_json_1 = __importDefault(require("./env/dev.json"));
9
+ const prod_json_1 = __importDefault(require("./env/prod.json"));
10
+ const stg_json_1 = __importDefault(require("./env/stg.json"));
11
+ exports.config = (0, ui_env_1.createConfig)({
12
+ [ui_env_1.Env.DEVELOPMENT]: dev_json_1.default,
13
+ [ui_env_1.Env.STAGING]: stg_json_1.default,
14
+ [ui_env_1.Env.PRODUCTION]: prod_json_1.default,
15
+ });
@@ -0,0 +1,5 @@
1
+ export * from "@mui/material";
2
+ import emotionCache from "@emotion/cache";
3
+ import emotionReact from "@emotion/react";
4
+ import emotionStyled from "@emotion/styled";
5
+ export { emotionReact, emotionStyled, emotionCache };
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.emotionCache = exports.emotionStyled = exports.emotionReact = void 0;
21
+ __exportStar(require("@mui/material"), exports);
22
+ const cache_1 = __importDefault(require("@emotion/cache"));
23
+ exports.emotionCache = cache_1.default;
24
+ const react_1 = __importDefault(require("@emotion/react"));
25
+ exports.emotionReact = react_1.default;
26
+ const styled_1 = __importDefault(require("@emotion/styled"));
27
+ exports.emotionStyled = styled_1.default;
@@ -0,0 +1,2 @@
1
+ export declare const light: import("@mui/material/styles").Theme;
2
+ export declare const dark: import("@mui/material/styles").Theme;
package/dist/theme.js ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dark = exports.light = void 0;
4
+ const styles_1 = require("@mui/material/styles");
5
+ const colors_1 = require("./colors");
6
+ function theme(type) {
7
+ const isDark = type === "dark";
8
+ const textColor = isDark ? colors_1.neutral.white : colors_1.neutral.black;
9
+ return {
10
+ palette: {
11
+ mode: type,
12
+ primary: {
13
+ main: colors_1.base.primary,
14
+ },
15
+ secondary: {
16
+ main: colors_1.neutral.white,
17
+ },
18
+ background: {
19
+ default: isDark ? colors_1.neutral.softBlack2 : colors_1.neutral.softWhite,
20
+ paper: isDark ? colors_1.neutral.softBlack1 : colors_1.neutral.white,
21
+ },
22
+ text: {
23
+ primary: colors_1.base.primary,
24
+ },
25
+ },
26
+ shape: {
27
+ borderRadius: 8,
28
+ },
29
+ typography: {
30
+ fontFamily: "Inter, -apple-system, system-ui, sans-serif",
31
+ h1: {
32
+ fontSize: 96,
33
+ fontWeight: 600,
34
+ marginBlock: "0.5em",
35
+ color: textColor,
36
+ },
37
+ h2: {
38
+ fontSize: 60,
39
+ fontWeight: 600,
40
+ marginBlock: "0.5em",
41
+ color: textColor,
42
+ },
43
+ h3: {
44
+ fontSize: 48,
45
+ fontWeight: 500,
46
+ marginBlock: "0.5em",
47
+ color: textColor,
48
+ },
49
+ h4: {
50
+ fontSize: 34,
51
+ fontWeight: 600,
52
+ marginBlock: "0.5em",
53
+ color: textColor,
54
+ },
55
+ h5: {
56
+ fontSize: 20,
57
+ fontWeight: 600,
58
+ marginBlock: "0.5em",
59
+ color: textColor,
60
+ },
61
+ button: {
62
+ textTransform: "uppercase",
63
+ fontWeight: 600,
64
+ },
65
+ body1: {
66
+ color: textColor,
67
+ },
68
+ body2: {
69
+ color: textColor,
70
+ },
71
+ },
72
+ };
73
+ }
74
+ exports.light = (0, styles_1.createTheme)(theme("light"));
75
+ exports.dark = (0, styles_1.createTheme)(theme("dark"));
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "decentraland-ui2",
3
+ "version": "0.0.0-9008705175.commit-ca18515",
4
+ "description": "Decentraland's UI components and styles",
5
+ "main": "index.js",
6
+ "author": "Decentraland",
7
+ "license": "Apache-2.0",
8
+ "scripts": {
9
+ "test": "jest",
10
+ "fix:prettier": "prettier --write ./src",
11
+ "start": "storybook dev -p 6006",
12
+ "build": "npm run build:dist",
13
+ "build:dist": "rm -Rf dist && tsc -p . -d --outDir dist --declarationDir dist --sourceMap false --skipLibCheck",
14
+ "build-storybook": "npm run generate:storybooks && npx storybook@7 build",
15
+ "format": "prettier --write '**/*.{ts,tsx,js,jsx,json,md,mdx,css}'",
16
+ "lint": "eslint --ext .ts,.tsx,.js,.jsx ./src",
17
+ "lint:check": "eslint --ext .ts,.tsx,.js,.jsx ./src",
18
+ "lint:fix": "npm run lint -- --fix",
19
+ "generate:storybooks": "ts-node ./bin/storybookGenerator.ts && npm run lint:fix"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/decentraland/ui2.git"
24
+ },
25
+ "keywords": [
26
+ "decentraland",
27
+ "ui",
28
+ "react",
29
+ "semantic-ui",
30
+ "components",
31
+ "styles",
32
+ "themes"
33
+ ],
34
+ "bugs": {
35
+ "url": "https://github.com/decentraland/ui2/issues"
36
+ },
37
+ "homepage": "https://github.com/decentraland/ui2#readme",
38
+ "dependencies": {
39
+ "@dcl/schemas": "^9.7.0",
40
+ "@dcl/ui-env": "^1.4.0",
41
+ "@emotion/react": "^11.11.1",
42
+ "@emotion/styled": "^11.11.0",
43
+ "@mui/icons-material": "^5.14.14",
44
+ "@mui/material": "^5.14.14",
45
+ "autoprefixer": "^10.4.16",
46
+ "radash": "^11.0.0",
47
+ "react": "^17.0.2",
48
+ "react-dom": "^17.0.2",
49
+ "react-tile-map": "^0.4.1"
50
+ },
51
+ "devDependencies": {
52
+ "@babel/preset-env": "^7.23.2",
53
+ "@babel/preset-react": "^7.22.15",
54
+ "@babel/preset-typescript": "^7.23.2",
55
+ "@dcl/eslint-config": "^1.1.12",
56
+ "@storybook/addon-docs": "^7.5.2",
57
+ "@storybook/addon-essentials": "^7.5.2",
58
+ "@storybook/addon-links": "^7.5.2",
59
+ "@storybook/addon-storysource": "^7.5.2",
60
+ "@storybook/addon-themes": "^7.5.2",
61
+ "@storybook/blocks": "^7.5.2",
62
+ "@storybook/react": "^7.5.2",
63
+ "@storybook/react-webpack5": "^7.5.2",
64
+ "@storybook/testing-library": "^0.2.2",
65
+ "@types/jest": "^29.5.12",
66
+ "@types/react": "^17.0.69",
67
+ "@typescript-eslint/eslint-plugin": "^6.8.0",
68
+ "@typescript-eslint/parser": "^6.8.0",
69
+ "eslint": "^8.51.0",
70
+ "eslint-config-prettier": "^9.0.0",
71
+ "eslint-import-resolver-babel-module": "^5.3.2",
72
+ "eslint-import-resolver-jest": "^3.0.2",
73
+ "eslint-import-resolver-typescript": "^3.6.1",
74
+ "eslint-plugin-autofix": "^1.1.0",
75
+ "eslint-plugin-css-import-order": "^1.1.0",
76
+ "eslint-plugin-import": "^2.28.1",
77
+ "eslint-plugin-prettier": "^5.0.0",
78
+ "eslint-plugin-storybook": "^0.6.15",
79
+ "jest": "^29.7.0",
80
+ "prettier": "^3.0.3",
81
+ "storybook": "^7.5.2",
82
+ "ts-jest": "^29.1.2",
83
+ "ts-node": "^10.9.1",
84
+ "typescript": "^5.2.2"
85
+ },
86
+ "files": [
87
+ "dist"
88
+ ],
89
+ "commit": "ca18515ed9c0b195c085361a61e752be0e3abedb"
90
+ }