Skip to content
Open
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
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# Solid React basic example
# Solid React basic example with TypeScript

This is a sample react application that uses solid components.

Documentation links:
- [React components for Solid](https://github.com/inrupt/solid-ui-react)
- [Solid UI-react documentation](https://solid-ui-react.docs.inrupt.com/)
- [Source code](https://github.com/inrupt/solid-ui-react)
- [Classes for handling the authentication](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-browser/)
- [Main documentation site](https://docs.inrupt.com/)

## How to
## Using the repository

Install dependencies

```bash
npm install
```

Run the code:

```
npm start
```

## Creating a SOLID app from scratch

First, create a React application with `npx create-react-app solid-react-example`. This command will create a react sample application in the directory solid-react-example.

Lets add a dependecy to this project. We want to use [solid components](https://github.com/inrupt/solid-ui-react), lets use npm to add the required dependencies:
Expand Down
5 changes: 5 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
transform: {
"^.+\\.tsx?$": "ts-jest"
},
}
22,077 changes: 22,035 additions & 42 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.7.0",
"@types/node": "^16.11.14",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.2",
"typescript": "^4.5.4",
"web-vitals": "^1.1.0"
},
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions src/App.js → src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import './App.css';
import { SessionProvider} from "@inrupt/solid-ui-react";
import { SessionProvider, useSession } from "@inrupt/solid-ui-react";
import { useState} from "react";
import LoginForm from "./components/LoginForm"
import ProfileViewer from "./components/ProfileViewer"
import { useSession } from "@inrupt/solid-ui-react/dist";

const App = () => {
//We use this state variable
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { FOAF, VCARD } from "@inrupt/lit-generated-vocab-common";

const ProfileViewer = () => {
const { session } = useSession();
const { webId } = session.info;

return (
<Container fixed>
<CombinedDataProvider datasetUrl={webId} thingUrl={webId}>
{session.info.webId ? (
<CombinedDataProvider
datasetUrl={session.info.webId}
thingUrl={session.info.webId}>
<Card style={{ maxWidth: 480 }}>
<CardContent>
<Typography gutterBottom variant="h5" component="h2">
Expand All @@ -25,11 +27,14 @@ const ProfileViewer = () => {
</CardActionArea>
</Card>
</CombinedDataProvider>
): null }
<LogoutButton >
<Button style={{ marginTop: 20 }} variant="contained" color="primary">
Logout
</Button>
</LogoutButton>


</Container>
);
}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
27 changes: 27 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src",
"e2e"
]
}