-
Notifications
You must be signed in to change notification settings - Fork 3
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
Example/static components #2
Open
AceMouty
wants to merge
5
commits into
solidjs-community:main
Choose a base branch
from
AceMouty:example/static-components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
452402e
feat: created basic example with stateless components
AceMouty e33df15
chore: removed uneeded styles
AceMouty 9068e82
chore: fixed typo in README
AceMouty 435cda9
chore: added screenshot of example
AceMouty a3c7796
chore: added in css reset attribution
AceMouty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Static Components | ||
|
||
A demo showing a simple site built with (non stateful) components using SolidJS | ||
|
||
Features: | ||
|
||
- CSS modules | ||
- Solid components (non stateful) | ||
- Global styling and custom props in `src/index.css` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.ico" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" | ||
/> | ||
<title>Solid App</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
|
||
<script src="/src/index.tsx" type="module"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "vite-template-solid", | ||
"version": "0.0.0", | ||
"description": "", | ||
"scripts": { | ||
"start": "vite", | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"typescript": "^4.6.4", | ||
"vite": "^2.9.9", | ||
"vite-plugin-solid": "^2.2.6" | ||
}, | ||
"dependencies": { | ||
"solid-js": "^1.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.App { | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Component } from 'solid-js'; | ||
|
||
import styles from './App.module.css'; | ||
import { CardGrid } from './components/CardGrid'; | ||
import { Navbar } from './components/Navbar'; | ||
import { Title } from './components/Title'; | ||
|
||
const App: Component = () => { | ||
return ( | ||
<div class={styles.App}> | ||
<Navbar /> | ||
<main> | ||
<Title /> | ||
<CardGrid /> | ||
</main> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
Binary file not shown.
39 changes: 39 additions & 0 deletions
39
examples/basic/static-components/src/components/CardGrid/CardGrid.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.grid { | ||
margin: 0 auto; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-wrap: wrap; | ||
max-width: 800px; | ||
margin-top: 3rem; | ||
} | ||
|
||
.card { | ||
margin: 1rem; | ||
flex-basis: 45%; | ||
padding: 1.5rem; | ||
text-align: left; | ||
color: inherit; | ||
text-decoration: none; | ||
border: 1px solid #eaeaea; | ||
border-radius: 10px; | ||
transition: color 0.15s ease, border-color 0.15s ease; | ||
} | ||
|
||
.card:hover, | ||
.card:focus, | ||
.card:active { | ||
color: var(--sLight-blue); | ||
border-color: var(--sLight-blue); | ||
} | ||
|
||
.card h3 { | ||
margin: 0 0 1rem 0; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.card p { | ||
margin: 0; | ||
font-size: 1.25rem; | ||
line-height: 1.5; | ||
} |
35 changes: 35 additions & 0 deletions
35
examples/basic/static-components/src/components/CardGrid/CardGrid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import styles from './CardGrid.module.css'; | ||
export default function CardGrid() { | ||
return ( | ||
<div class={styles.grid}> | ||
<a href="https://www.solidjs.com/" target="_new" class={styles.card}> | ||
<h3>Documentation →</h3> | ||
<p>Find comprehensive information about Solid features and API.</p> | ||
</a> | ||
|
||
<a | ||
href="https://www.solidjs.com/tutorial/introduction_basics" | ||
target="_new" | ||
class={styles.card} | ||
> | ||
<h3>Learn →</h3> | ||
<p>Learn Solid through our interactive tutorial!</p> | ||
</a> | ||
|
||
<a href="https://www.solidjs.com/examples/counter" target="_new" class={styles.card}> | ||
<h3>Examples →</h3> | ||
<p>Checkout our gallery of Solid example projects.</p> | ||
</a> | ||
|
||
<a href="https://www.solidjs.com/examples/counter" target="_new" class={styles.card}> | ||
<h3>Play →</h3> | ||
<p>Visit the playground to test ideas and see Solid compiled output!</p> | ||
</a> | ||
|
||
<a href="https://netlify.com" target="_new" class={styles.card}> | ||
<h3>Deploy →</h3> | ||
<p>Instantly deploy your Solid app to a public URL with Netlify.</p> | ||
</a> | ||
</div> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
examples/basic/static-components/src/components/CardGrid/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as CardGrid } from './CardGrid'; |
16 changes: 16 additions & 0 deletions
16
examples/basic/static-components/src/components/Navbar/Navbar.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.nav { | ||
background-color: var(--sLight-blue); | ||
padding: 1.5rem 3rem; | ||
} | ||
|
||
.nav > div { | ||
max-width: 800px; | ||
margin: 0 auto; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.logo { | ||
width: 2.25rem; | ||
pointer-events: none; | ||
} |
14 changes: 14 additions & 0 deletions
14
examples/basic/static-components/src/components/Navbar/Navbar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import styles from './Navbar.module.css'; | ||
import logo from '../../logo.svg'; | ||
import { SocialList } from '../SocialList'; | ||
|
||
export default function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a name to the function here, for consistency sake? |
||
return ( | ||
<div class={styles.nav}> | ||
<div> | ||
<img src={logo} alt="logo" class={styles.logo} /> | ||
<SocialList /> | ||
</div> | ||
</div> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
examples/basic/static-components/src/components/Navbar/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Navbar } from './Navbar'; |
14 changes: 14 additions & 0 deletions
14
examples/basic/static-components/src/components/SocialList/SocialList.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.socialList { | ||
margin: 0; | ||
padding: 0; | ||
display: flex; | ||
} | ||
|
||
.socialList > li { | ||
margin-left: 0.5rem; | ||
} | ||
|
||
.socialList i { | ||
font-size: 2rem; | ||
color: white; | ||
} |
31 changes: 31 additions & 0 deletions
31
examples/basic/static-components/src/components/SocialList/SocialList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import styles from './SocialList.module.css'; | ||
export default function SocialList() { | ||
return ( | ||
<ul role="list" class={styles.socialList}> | ||
<li> | ||
<a href="https://github.com/solidjs/solid"> | ||
<span class="sr-only">Navigate to Github</span> | ||
<i class="fa-brands fa-github-square"></i> | ||
</a> | ||
</li> | ||
<li> | ||
<a href="https://www.reddit.com/r/solidjs/"> | ||
<span class="sr-only">Navigate to Reddit</span> | ||
<i class="fa-brands fa-reddit-square"></i> | ||
</a> | ||
</li> | ||
<li> | ||
<a href="https://discord.com/invite/solidjs"> | ||
<span class="sr-only">Navigate to Discord</span> | ||
<i class="fa-brands fa-discord"></i> | ||
</a> | ||
</li> | ||
<li> | ||
<a href="https://twitter.com/solid_js"> | ||
<span class="sr-only">Navigate to Twitter</span> | ||
<i class="fa-brands fa-twitter-square"></i> | ||
</a> | ||
</li> | ||
</ul> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
examples/basic/static-components/src/components/SocialList/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as SocialList } from './SocialList'; |
11 changes: 11 additions & 0 deletions
11
examples/basic/static-components/src/components/Title/Title.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.title { | ||
margin: 0 auto; | ||
line-height: 1.15; | ||
font-size: 4rem; | ||
margin-top: 3rem; | ||
max-width: 700px; | ||
} | ||
|
||
.title span { | ||
color: var(--sLight-blue); | ||
} |
8 changes: 8 additions & 0 deletions
8
examples/basic/static-components/src/components/Title/Title.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import styles from './Title.module.css'; | ||
export default function Title() { | ||
return ( | ||
<h1 class={styles.title}> | ||
Simple and performant, <span>SolidJS!</span> | ||
</h1> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Title } from './Title'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
{{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe cite https://piccalil.li/blog/a-modern-css-reset/? |
||
CSS RESET | ||
*/ | ||
|
||
/* Box sizing rules */ | ||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: border-box; | ||
} | ||
|
||
/* Remove default margin */ | ||
body, | ||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
p, | ||
figure, | ||
blockquote, | ||
dl, | ||
dd { | ||
margin: 0; | ||
} | ||
|
||
/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */ | ||
ul[role='list'], | ||
ol[role='list'] { | ||
list-style: none; | ||
} | ||
|
||
/* Set core root defaults */ | ||
html:focus-within { | ||
scroll-behavior: smooth; | ||
} | ||
|
||
/* Set core body defaults */ | ||
body { | ||
min-height: 100vh; | ||
text-rendering: optimizeSpeed; | ||
line-height: 1.5; | ||
} | ||
|
||
/* A elements that don't have a class get default styles */ | ||
a:not([class]) { | ||
text-decoration-skip-ink: auto; | ||
} | ||
|
||
/* Make images easier to work with */ | ||
img, | ||
picture { | ||
max-width: 100%; | ||
display: block; | ||
} | ||
|
||
/* Inherit fonts for inputs and buttons */ | ||
input, | ||
button, | ||
textarea, | ||
select { | ||
font: inherit; | ||
} | ||
|
||
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */ | ||
@media (prefers-reduced-motion: reduce) { | ||
html:focus-within { | ||
scroll-behavior: auto; | ||
} | ||
|
||
*, | ||
*::before, | ||
*::after { | ||
animation-duration: 0.01ms !important; | ||
animation-iteration-count: 1 !important; | ||
transition-duration: 0.01ms !important; | ||
scroll-behavior: auto !important; | ||
} | ||
} | ||
/* | ||
end CSS reset | ||
}} | ||
*/ | ||
|
||
:root { | ||
--sLight-blue: #446b9e; | ||
} | ||
body { | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, | ||
Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; | ||
} | ||
|
||
.sr-only { | ||
position: absolute; | ||
width: 1px; | ||
height: 1px; | ||
padding: 0; | ||
margin: -1px; | ||
overflow: hidden; | ||
clip: rect(0, 0, 0, 0); | ||
white-space: nowrap; | ||
border-width: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* @refresh reload */ | ||
import { render } from 'solid-js/web'; | ||
|
||
import './index.css'; | ||
import App from './App'; | ||
|
||
render(() => <App />, document.getElementById('root') as HTMLElement); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that one common style should be used for Components, I think that export default function FunctionName is also used in the tutorial on site. So export default function App here?