Skip to content

Commit

Permalink
Merge pull request #524 from chatch/update-react-18-remix
Browse files Browse the repository at this point in the history
Update to react 18  and use remix.run
  • Loading branch information
chatch authored Sep 7, 2023
2 parents 49e715a + 7c7051d commit bd71cfa
Show file tree
Hide file tree
Showing 254 changed files with 23,730 additions and 38,507 deletions.
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

junit.xml

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
.vscode
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock

.gitsigners

# remix
/.cache
/build
/public/build
.env
19 changes: 9 additions & 10 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:

strategy:
matrix:
node-version: [14.x] # TODO: add back in latest LTS and drop 14 after stack upgrade
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -30,12 +29,12 @@ jobs:

- run: npm ci
- run: npm run build --if-present
- run: npm test
# - run: npm test

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Test Results # Name that shows up in the sidebar in github actions
path: junit.xml
reporter: jest-junit
# - name: Test Report
# uses: dorny/test-reporter@v1
# if: success() || failure() # run this step even if previous step failed
# with:
# name: Test Results # Name that shows up in the sidebar in github actions
# path: junit.xml
# reporter: jest-junit
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ yarn-error.log*
yarn.lock

.gitsigners

# remix
/.cache
/build
/public/build
.env
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.17.0
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Remix"

# Remix app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y build-essential pkg-config python-is-python3

# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci --include=dev

# Copy application code
COPY --link . .

# Build application
RUN npm run build

# Remove development dependencies
RUN npm prune --omit=dev


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "start" ]
210 changes: 210 additions & 0 deletions app/SearchBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@

import Col from "react-bootstrap/Col"
import Container from "react-bootstrap/Container"
import Row from "react-bootstrap/Row"
import FormControl from "react-bootstrap/FormControl"
import InputGroup from "react-bootstrap/InputGroup"
import Modal from "react-bootstrap/Modal"

import { useIntl } from "react-intl"

import { searchStrToPath } from "./lib/search"
import { isSecretKey } from "./lib/stellar/utils"
import { useState } from "react"
import { useNavigate } from "@remix-run/react"

import searchSvg from '../public/search.svg'
import infoCircleSvg from '../public/info-circle.svg'

const HelpModal = ({ showHelp, handleCloseFn }: { showHelp: boolean, handleCloseFn: () => void }) => (
<Modal id="help-modal" show={showHelp} onHide={handleCloseFn}>
<Modal.Header closeButton>
<Modal.Title>
Search Help
</Modal.Title>
</Modal.Header>
<Modal.Body style={{ color: "#96a2b4" }}>
<div>
<div className="search-sub-heading">Stellar Address</div>
<div className="search-desc">Also called a{" "}
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.stellar.org/developers/guides/concepts/federation.html#stellar-addresses"
>
Stellar federated address
</a>
<img
src="/search/search_stellar_address.png"
alt="search by ledger"
/>
</div>
</div>
<div>
<div className="search-sub-heading">Account ID</div>
<div className="search-desc">
Also called a Public Key or Public Address
<img
src="/search/search_account_public.png"
alt="search by public account address"
width="100%"
/>
</div>
</div>
<div>
<div className="search-sub-heading">Transaction Hash</div>
<img
src="/search/search_tx_hash.png"
alt="search by transaction hash"
width="100%"
/>
</div>
<div>
<div className="search-sub-heading">Contract Address or Hash</div>
<img
src="/search/search_contract.png"
alt="search by contract address"
width="100%"
/>
</div>
<div>
<div className="search-sub-heading">Ledger</div>
<img
src="/search/search_ledger.png"
alt="search by ledger"
/>
</div>
<div className="search-sub-heading">Anchor Name</div>
<div>
<div className="search-desc">
as listed on the{" "}
<a
target="_blank"
rel="noopener noreferrer"
href="https://steexp.com/anchors"
>
Anchors Page
</a>
</div>
<div>
<br />
<div className="search-desc">
<div>Full name:</div>
<img
src="/search/search_anchor_name_full.png"
alt="search by anchor full name"
/>
</div>
<br />
<div className="search-desc">
<div>Partial name:</div>
<img
src="/search/search_anchor_name_partial.png"
alt="search by anchor partial name"
/>
</div>
</div>
</div>
<div>
<div className="search-sub-heading">Asset Code</div>
<img
src="/search/search_asset.png"
alt="search by asset code"
/>
</div>
<hr />
<h4>OpenSearch:</h4>
<div>
Stellar Explorer supports{" "}
<a
target="_blank"
rel="noopener noreferrer"
href="https://developer.mozilla.org/en-US/docs/Web/OpenSearch"
>
OpenSearch
</a>
. This allows you to search directly from your browser search box or
search bar. You should see something like the following when you
navigate to Stellar Explorer then open the search box. Install it from
there:
<br />
<img
src="https://user-images.githubusercontent.com/1477978/33513399-8cf8ac52-d774-11e7-9585-ddc5467a5a2d.png"
alt="search by transaction hash"
width="80%"
/>
</div>
</Modal.Body>
</Modal>
)

export default function SearchBox() {
const { formatMessage } = useIntl()

const [searchStr, setSearchStr] = useState('')
const [showHelp, setShowHelp] = useState(false)

const navigate = useNavigate()

const handleCloseFn = () => setShowHelp(false)
const handleClickFn = () => setShowHelp(true)

const searchHandler = (event: any) => {
console.log(`searchHandler entry [${searchStr}]`)
event.preventDefault()

const matchPath = searchStrToPath(searchStr)
console.log(`matchPath ${matchPath}`)

// #62 security: clear search box if user put the secret key there
if (isSecretKey(searchStr)) {
setSearchStr("")
}

if (matchPath == null)
return

return navigate(matchPath)
}

return (
<Container>
<Row>
<Col id="search-container">
<form onSubmit={searchHandler}>
<InputGroup>
<FormControl
type="text"
onChange={(e) => setSearchStr(e.target.value)}
placeholder={formatMessage({
id: "search.placeHolder",
})}
value={searchStr}
/>
<InputGroup.Text>
<img
src={searchSvg}
style={{ color: '#4c5667', height: 16, width: 16 }}
onClick={searchHandler}
/>
</InputGroup.Text>
<InputGroup.Text style={{ background: 'none', border: 0, color: 'white', fontSize: 20 }}>
<img
src={infoCircleSvg}
style={{ color: 'white', height: 24, width: 24 }}
onClick={handleClickFn}
/>
</InputGroup.Text>
</InputGroup>
</form>
{showHelp && (
<HelpModal
handleCloseFn={handleCloseFn}
showHelp={showHelp}
/>
)}
</Col>
</Row>
</Container>
)
}
Loading

0 comments on commit bd71cfa

Please sign in to comment.