Skip to content

Commit acc7ab1

Browse files
committed
added M3terAlias component
1 parent 27249f4 commit acc7ab1

File tree

15 files changed

+1994
-14
lines changed

15 files changed

+1994
-14
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
# m3ters.js
1+
# `m3ters.js`
22
React toolkit tailored to M3tering Protocol for handling ugly crypto strings
33

44
## Features
5-
- **Human-Readable Hashes:** Easily convert complex cryptographic strings into easily understandable and visually appealing human-readable hashes.
5+
- **[M3ter Alias](./docs/m3ter-alias.md#m3ter-alias): Human-Readable Hashes:** Easily convert complex cryptographic strings into easily understandable and visually appealing human-readable hashes.
66

77
- **[M3ter Head](./docs/m3ter-head.md#M3ter-Head): Unique SVG Avatars** Generate one-of-a-kind SVG avatars that serve as distinctive visual representations for device DIDs and blockchain address strings commonly encountered in the M3tering Protocol.
88

99
## Installation
1010

11-
1. Add the `m3ter-head` component to your project using npm:
11+
1. Add the `m3ters.js` component to your project using npm:
1212

1313
```bash
1414
npm install m3ters --save
1515
```
16+
17+
## Example App
18+
19+
Check out my [demo m3ters](https://github.com/ichristwin/demo-m3ters) for a sample React project incorporating the `m3ters.js` library. Additionally, you can experience the live implementation of `m3ters.js` at https://m3ters.ichristwin.com.
20+
21+
### Other projects using `m3ters.js`
22+
-

docs/m3ter-alias.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# M3ter Alias
2+
3+
Effortlessly create captivating names that instantly distinguish each device, and introduce a touch of personality.
4+
5+
### Usage:
6+
7+
1. Import the `M3terAlias` component into your React code:
8+
9+
```javascript
10+
import * as React from "react";
11+
import { M3terAlias } from "m3ters";
12+
```
13+
14+
2. Render the alias within your component, providing a unique seed string for generation:
15+
16+
```jsx
17+
export default function Home() {
18+
return (
19+
<h2 style={{ "text-transform": "capitalize" }}>
20+
<M3terAlias seed={"device_DID_string"} />
21+
</h2>
22+
);
23+
}
24+
```
25+
26+
3. Your browser should render text content like shown below
27+
<h2><p align="center">Mighty Distinct Nanogear</p></h2>
28+
29+
## Credits
30+
31+
Inspired by a similar JavaScript library, [angry-purple-tiger](https://github.com/helium/angry-purple-tiger) developed by [Andrew Allen](https://twitter.com/allenan_) for the Helium Network.
32+
33+
34+
## Licensing
35+
36+
You are free to embed under the terms of the [CC0 1.0 Universal](./LICENSE) License.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
},
4343
"type": "module",
4444
"source": "src/index.js",
45-
"main": "dist/index.cjs",
46-
"module": "dist/index.js",
45+
"main": "dist/cjs/index.cjs",
46+
"module": "dist/esm/index.js",
4747
"files": [
4848
"dist"
4949
]

rollup.config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ export default [
99
external: [/@babel\/core/, /@babel\/preset-react/, /react/, /react-dom/],
1010
output: [
1111
{
12-
file: "dist/index.cjs",
12+
dir: "dist/cjs/",
1313
format: "cjs",
14+
sourcemap: true,
15+
entryFileNames: "[name].cjs",
1416
},
1517
{
16-
file: "dist/index.js",
17-
format: "es",
18+
dir: "dist/esm/",
19+
format: "esm",
1820
exports: "named",
21+
sourcemap: true,
22+
entryFileNames: "[name].js",
1923
},
2024
],
2125
plugins: [

src/components/M3terAlias.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react";
2+
import seedrandom from "seedrandom";
3+
4+
import { Adjectives, Nouns } from "../words";
5+
6+
export const M3terAlias = (seed) => {
7+
const random = seedrandom(seed);
8+
let adj1 = Math.round(random() * 1808);
9+
let adj2 = Math.round(random() * 1808);
10+
let noun = Math.round(random() * 96);
11+
12+
return (
13+
<>
14+
{Adjectives[adj1]} {Adjectives[adj2]} {Nouns[noun]}
15+
</>
16+
);
17+
};

src/components/M3terHead.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
2+
import seedrandom from "seedrandom";
3+
24
import { Eyes } from "./Eyes";
35
import { Mouth } from "./Mouth";
46
import { Texture } from "./Texture";
57

6-
import seedrandom from "seedrandom";
7-
88
export const M3terHead = (seed) => {
99
const random = seedrandom(seed);
1010
let eyes = Math.round(random() * 15);

src/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import React from 'react';
22

3+
export * from "./M3terAlias.jsx";
34
export * from "./M3terHead.jsx";

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import React from 'react';
1+
import React from "react";
22

33
export * from "./components";

src/parts/Eyes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React from "react";
22

33
export { Arturito } from "./Arturito";
44
export { Bulging } from "./Bulging";

0 commit comments

Comments
 (0)