Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include usage examples in README #21

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 58 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ environment are provided below.
- Staging: https://staging.ud.me/aaron.x
- Production: https://ud.me/quirk.x

## Usage

The React components contained in the `domain-profiles` project can be used in
your own project, and imported directly from NPM. Some of the components
available are:

- Unstoppable Messaging
- Token Gallery
- Wallet connect modal

### Installation

To use the Unstoppable Domains React components in your own project, install the
Expand All @@ -55,7 +45,62 @@ npm install react react-dom
yarn add react react-dom
```

### Developing
## Usage

The React components contained in the `domain-profiles` project can be used in
your own project, and imported directly from NPM. Some of the components
available are:

- Unstoppable Messaging
- Token Gallery
- Wallet connect modal

As an example, the following demonstrates how to add Unstoppable Messaging to your
existing Web3 React dApp.

```typescript
import Button from '@mui/material/Button';
import {
UnstoppableMessaging,
UnstoppableMessagingProvider,
Web3ContextProvider,
useUnstoppableMessaging,
} from '@unstoppabledomains/ui-components';

// Hardcoded user information as an example. This information should come
// from a connected wallet in a real world scenario.
const myAddress = "0x123";
const myDomain = "mydomain.x";

const MyPage = () => {

// Hook provides utility methods, such as opening the Unstoppable
// Messaging window by clicking a button
const {setOpenChat} = useUnstoppableMessaging();

return (
<Web3ContextProvider>
<UnstoppableMessagingProvider>
<div>
<UnstoppableMessaging
address={myAddress}
domain={myDomain}
/>
</div>
<Button
onClick={() => setOpenChat("friend.x")}
>
Open chat
</Button>
</UnstoppableMessagingProvider>
</Web3ContextProvider>
)
}

export default as MyPage;
```

## Contributing

To contribute changes to the `domain-profiles` project, you'll need to clone the
project and build it in your local environment.
Expand All @@ -78,8 +123,8 @@ yarn workspace server run dev
To run the tests (`src/**/*.test.tsx` files):

```shell
yarn test # run all tests
yarn test:coverage # run all tests and generate coverage report
yarn test # run all tests
yarn test:ci # run all tests and generate coverage report
```

### Linting and code formatting
Expand Down
9 changes: 9 additions & 0 deletions packages/config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Change Log

All notable changes to this project will be documented in this file. This
project adheres to [Semantic Versioning](http://semver.org/).

## 0.0.2

- Update the README to include usage examples

## 0.0.1

- Initial version
60 changes: 60 additions & 0 deletions packages/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Unstoppable Domains Config

A common configuration reference for Unstoppable Domains environments 🛠️

[![CI Status](https://github.com/unstoppabledomains/domain-profiles/actions/workflows/push.yml/badge.svg)](https://github.com/unstoppabledomains/domain-profiles/actions/workflows/push.yml)

### Installation

To use the Unstoppable Domains config in your own project, install the
module in your project directory:

```shell
// with npm
npm install --save @unstoppabledomains/config

// with yarn
yarn add @unstoppabledomains/config
```

## Usage

```typescript
import config from '@unstoppabledomains/config';

console.log("Unstoppable Domains smart contract", config.UNSTOPPABLE_CONTRACT_ADDRESS);
```

## Contributing

To contribute changes to the `domain-profiles` project, you'll need to clone the
project and build it in your local environment.

```shell
# Clone the project
git clone [email protected]:unstoppabledomains/domain-profiles.git
cd domain-profiles

# Build the project locally
yarn install # install dependencies
yarn build # build shared packages

# Run the development server
yarn workspace server run dev
```

### Testing

To run the tests (`src/**/*.test.tsx` files):

```shell
yarn test # run all tests
yarn test:ci # run all tests and generate coverage report
```

### Linting and code formatting

```shell
yarn lint # automatically fixes linting errors
yarn format # checks for formatting errors
```
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unstoppabledomains/config",
"version": "0.0.1",
"version": "0.0.2",
"private": true,
"description": "Configuration variables for Unstoppable Domains environments",
"homepage": "https://github.com/unstoppabledomains/domain-profiles#readme",
Expand Down
2 changes: 1 addition & 1 deletion scripts/copyPackageFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ cd packages/ui-components \
&&
# Prepare the config package
cd packages/config \
&& cp -rf CHANGELOG.md ../../README.md ../../LICENSE build/src \
&& cp -rf CHANGELOG.md README.md ../../LICENSE build/src \
&& cat package.json | sed -e 's/build\/src\///g' | sed -e 's/workspace:\^/latest/g' | sed -e 's/"private": true/"private": false/g' > build/src/package.json \
&& cd ../../
Loading