-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Replace primer.css with webext-base-css #895
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2c2907c
Replace primer.css with webext-base-css
fregante 91dd16e
Fix selector for Chrome
fregante 25f988f
Lint
fregante 2e11203
Fix sizing issue in Edge
fregante bc750eb
Update yarn.lock
fregante 782216a
Add styling to sccuess message
stefanbuck bb760fb
Adjust code-tag font-size to match base font-size
stefanbuck 724d368
Set input as invalid if errorMessage is set
stefanbuck 238e32b
Disabled depreacted jsx-a11y/label-has-for rule
stefanbuck b8697df
Tweak token error message
stefanbuck 5efabe2
Avoid form jump on success message
stefanbuck 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
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
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 |
---|---|---|
|
@@ -34,6 +34,11 @@ export default class Form extends Component { | |
async validateToken() { | ||
const { githubToken } = this.state; | ||
|
||
if (!this.tokenInputEl) { | ||
this.tokenInputEl = document.querySelector('.js-token'); | ||
} | ||
this.tokenInputEl.setCustomValidity(''); | ||
|
||
if (!githubToken) { | ||
this.setState({ | ||
errorMessage: undefined, | ||
|
@@ -53,8 +58,18 @@ export default class Form extends Component { | |
if (!response.login) { | ||
this.setState({ | ||
tokenLoaded: false, | ||
errorMessage: response.message || 'Something went wrong', | ||
}); | ||
|
||
let message = 'The token could not be validated'; | ||
if ( | ||
response.message && | ||
response.message.toLowerCase() === 'bad credentials' | ||
) { | ||
message = 'Your token is not valid'; | ||
} | ||
|
||
this.tokenInputEl.setCustomValidity(message); | ||
this.tokenInputEl.reportValidity(); | ||
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. This solution is inspirited by https://github.com/developit/preact-mdl/blob/master/src/index.js#L873-L878 so it shouldn't be completely wrong 😉 |
||
return; | ||
} | ||
|
||
|
@@ -68,10 +83,6 @@ export default class Form extends Component { | |
}); | ||
} | ||
|
||
tokenMessage() { | ||
return <div className="flash flash-success">Token successfully added</div>; | ||
} | ||
|
||
render(props, state) { | ||
const { errorMessage, tokenLoaded } = this.state; | ||
|
||
|
@@ -80,10 +91,13 @@ export default class Form extends Component { | |
onChange={this.onBlur.bind(this)} | ||
onSubmit={(event) => event.preventDefault()} | ||
> | ||
{tokenLoaded && this.tokenMessage()} | ||
<div className="flash-success"> | ||
{tokenLoaded && '✔ Token successfully added!'} | ||
</div> | ||
<Input | ||
type="password" | ||
name="githubToken" | ||
className="js-token" | ||
label="Access token" | ||
description={githubTokenDescription()} | ||
value={state.githubToken} | ||
|
@@ -93,7 +107,7 @@ export default class Form extends Component { | |
setTimeout(this.validateToken.bind(this), 100); | ||
}} | ||
/> | ||
<p className="note "> | ||
<p> | ||
For public repositories,{' '} | ||
<a | ||
href="https://github.com/settings/tokens/new?scopes=public_repo&description=OctoLinker" | ||
|
@@ -120,9 +134,11 @@ export default class Form extends Component { | |
<strong>repo</strong> | ||
</code>{' '} | ||
permissions. Then copy and paste it into the input field above. | ||
<details className="mt-3"> | ||
</p> | ||
<p> | ||
<details> | ||
<summary>Why is a GitHub token needed?</summary> | ||
<p className="note"> | ||
<p> | ||
OctoLinker uses the{' '} | ||
<a | ||
href="https://developer.github.com/v3/" | ||
|
@@ -135,7 +151,7 @@ export default class Form extends Component { | |
unauthenticated requests to the GitHub API. However, there are two | ||
situations when requests must be authenticated: | ||
</p> | ||
<p className="note ml-5"> | ||
<p> | ||
<ul> | ||
<li>You access a private repository</li> | ||
<li> | ||
|
@@ -150,7 +166,7 @@ export default class Form extends Component { | |
</li> | ||
</ul> | ||
</p> | ||
<p className="note"> | ||
<p> | ||
When that happens, OctoLinker needs an GitHub access token in | ||
order to continue to work. | ||
</p> | ||
|
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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { h } from 'preact'; | ||
|
||
export default ({ name, label, description, checked, onClick }) => ( | ||
<div className="form-checkbox"> | ||
<label htmlFor={name}> | ||
<input | ||
id={name} | ||
name={name} | ||
type="checkbox" | ||
checked={checked} | ||
onClick={onClick} | ||
/> | ||
{label} | ||
</label> | ||
<p className="note">{description}</p> | ||
</div> | ||
<p className="form-checkbox"> | ||
<input | ||
id={name} | ||
name={name} | ||
type="checkbox" | ||
checked={checked} | ||
onClick={onClick} | ||
/> | ||
<span> | ||
<label htmlFor={name}>{label}</label> | ||
<br /> | ||
<span className="note">{description}</span> | ||
</span> | ||
</p> | ||
); |
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import 'primer-core/build/build.css'; | ||
import 'primer-forms/build/build.css'; | ||
import 'primer-product/build/build.css'; | ||
import 'webext-base-css'; | ||
|
||
export { default as Input } from './input'; | ||
export { default as Checkbox } from './checkbox'; |
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 |
---|---|---|
@@ -1,36 +1,29 @@ | ||
/* eslint jsx-a11y/label-has-for: 0 */ | ||
|
||
import { h } from 'preact'; | ||
|
||
const validationClassName = (error) => (error ? ' errored' : ''); | ||
|
||
export default ({ | ||
name, | ||
label, | ||
description, | ||
error, | ||
value, | ||
onInput, | ||
className, | ||
type = 'text', | ||
}) => ( | ||
<dl className={`form-group${validationClassName(error)}`}> | ||
<dt> | ||
<label htmlFor={name} id={name}> | ||
{label} | ||
</label> | ||
</dt> | ||
<dd> | ||
<input | ||
style={{ width: '100%' }} | ||
className="form-control" | ||
type={type} | ||
id={name} | ||
name={name} | ||
value={value} | ||
onInput={onInput} | ||
/> | ||
</dd> | ||
{error && <dd className="error">{error}</dd>} | ||
<p className="note">{description}</p> | ||
</dl> | ||
<p> | ||
<label htmlFor={name} id={name}> | ||
<strong>{label}</strong> | ||
</label> | ||
|
||
<input | ||
style={{ width: '100%' }} | ||
className={className} | ||
type={type} | ||
id={name} | ||
name={name} | ||
value={value} | ||
onInput={onInput} | ||
/> | ||
|
||
<div className="note">{description}</div> | ||
</p> | ||
); |
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
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
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 |
---|---|---|
@@ -1,11 +1,36 @@ | ||
body { | ||
html { | ||
user-select: none; | ||
} | ||
|
||
label { | ||
font-size: 12px; | ||
body, p { /* p required to override chrome_style */ | ||
line-height: 1.5; | ||
} | ||
|
||
.form-checkbox input[type=checkbox], .form-checkbox input[type=radio] { | ||
margin-top: 2px; | ||
.form-checkbox { | ||
display: flex; | ||
} | ||
|
||
code { | ||
font-size: 1rem; | ||
} | ||
|
||
.note { | ||
display: block; | ||
opacity: 0.6; | ||
} | ||
|
||
input[type='checkbox'] { | ||
margin-inline-end: 0.6em; | ||
margin-top: 0.2em; | ||
} | ||
|
||
.flash-success { | ||
height: 0.5rem; | ||
text-align: center; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
.flash-success { | ||
color: #165c26; | ||
} | ||
} |
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.
Do you know if this is supposed to work in MS Edge as well? The readme of webext-base-css mentions just Firefox. I'm asking because it looks like they added their own protocol
edge://
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.
Indeed, this only loads in Firefox. Firefox effectively doesn't support
options.chrome_style
so thankfully this stylesheet fills in.I don't know how it looks in Edge, but I assume it just matches Chrome.