This repository has been archived by the owner on Nov 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from illright/v3
Version 3
- Loading branch information
Showing
131 changed files
with
1,465 additions
and
1,042 deletions.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
__sapper__ | ||
dist | ||
README.md |
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,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"arrowParens": "avoid", | ||
"svelteSortOrder": "scripts-markup-styles", | ||
"svelteSortOrder": "options-scripts-markup-styles", | ||
"svelteBracketNewLine": true | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Maintainer's Guide | ||
|
||
Notes to self and quirks of the project's implementation in case all of the current maintainers get hit by the same bus. | ||
|
||
## Why we use Sass | ||
|
||
- A lot of the colors are computed with Sass color functions, switching to CSS variables would mean a whole lot more variables. | ||
- Using Sass variables instead of CSS variables gives us more browser compatibility. | ||
|
||
## Why we use Sass so strangely | ||
|
||
Specifically talking about how most of the components have the following line: | ||
|
||
```scss | ||
@use 'node_modules/attractions/_variables'; | ||
``` | ||
|
||
That path doesn't exist for us, library developers, but it does exist for the users who installed this library and are now compiling SCSS. This is done to enable zero-config installation for those users who are not interested in changing Sass variables or using them in their own stylesheets. | ||
|
||
So how does it work? Glad you asked. | ||
Sass has several stages of resolution when it comes to imports: | ||
|
||
> 1. Loading a file relative to the file in which the `@use` or `@import` appeared. | ||
> | ||
> 2. Each custom importer. | ||
> | ||
> 3. Loading a file relative to the current working directory. | ||
> | ||
> 4. Each load path in `includePaths` | ||
> | ||
> 5. Each load path specified in the `SASS_PATH` environment variable, which should be semicolon-separated on Windows and colon-separated elsewhere. | ||
The trick is to utilize the steps after the second so that the users who want to configure their installation could intercept the resolution chain at step 2. | ||
Particularly, this import uses step 3 (reminding you that the current working directory is the one your terminal is at when running the compilation command, which is probably the same one that holds `rollup.config.js`). Thus, if there are no importers, step 1 fails, step 2 fails, and step 3 resolves. | ||
We too can intercept the chain at step 2 when building the library, so it's okay that the path doesn't exist – our building code will not fail. | ||
|
||
Sass mixins, on the other hand, never need to be overridden, so it's okay to import them with step 1 (`@use '../_mixins';`). |
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,57 @@ | ||
# Migration Guide | ||
|
||
Here you may find guidance on upgrading Attractions from one major version to another. | ||
|
||
## From v2.x to v3.x | ||
|
||
The main change in version 3 is the migration to Sass modules. | ||
|
||
If you have existing code that used Sass for styling and was using the old `@import` statements, consider using the automatic [Sass Migrator](https://sass-lang.com/documentation/cli/migrator) tool first. | ||
|
||
**Heads up**: if your styles used imports that relied on `includePaths`, you can still make Sass Migrator understand them by setting the `SASS_PATH` environment variable to the path that you previously had in your `includePaths` Sass compiler option. | ||
|
||
Once your code is ready for Sass modules, replace Node Sass (`node-sass`) with Dart Sass (`sass`). | ||
|
||
Update your `rollup.config.js` to use the new Attractions importers: | ||
|
||
```js | ||
import autoPreprocess from 'svelte-preprocess'; | ||
import makeAttractionsImporter from 'attractions/importer.js'; | ||
|
||
const preprocessChain = [ | ||
autoPreprocess({ | ||
scss: { | ||
importer: makeAttractionsImporter({ | ||
// If you previously had a file that was overriding Attractions variables, | ||
// provide the path to it here. | ||
// If it was empty, you may delete it, omit this parameter | ||
// and call the function with no arguments. | ||
themeFile: './static/css/_attractions-theme.scss', | ||
}), | ||
|
||
includePaths: ['./static/css'], | ||
}, | ||
}), | ||
]; | ||
``` | ||
|
||
Lastly, if your `_attractions-theme.scss` had any variable overrides, move them to the module configuration. | ||
|
||
Before: | ||
|
||
```scss | ||
@import '_attractions-theme.scss'; | ||
$font: 'Open Sans', sans-serif; | ||
$main: green; | ||
$my-custom-variable: 1px; | ||
``` | ||
|
||
After: | ||
|
||
```scss | ||
@forward "~attractions/_variables" with ( | ||
$font: ('Open Sans', sans-serif), | ||
$main: green; | ||
); | ||
$my-custom-variable: 1px; | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@use 'sass:color'; | ||
@use 'node_modules/attractions/_variables' as vars; | ||
|
||
@mixin text-field { | ||
padding: 0 0.625em 0.0625em; | ||
box-sizing: border-box; | ||
width: 100%; | ||
border: 0 solid vars.$textfield-border; // to disable the global border | ||
border-bottom-width: 0.0625em; | ||
border-top-left-radius: 0.375em; | ||
border-top-right-radius: 0.375em; | ||
background-color: vars.$textfield-bg; | ||
|
||
&:hover { | ||
background-color: color.scale(vars.$textfield-bg, $lightness: -3%); | ||
} | ||
} | ||
|
||
@mixin text-field-focused { | ||
background-color: color.scale(vars.$textfield-bg, $lightness: -8%); | ||
border-bottom-width: 0.125em; | ||
border-color: color.scale(vars.$main, $lightness: 4%); | ||
padding-bottom: 0; | ||
} | ||
|
||
@mixin text-field-disabled { | ||
background-color: color.scale(vars.$textfield-bg, $lightness: 15%); | ||
border-color: color.adjust(vars.$dark, $alpha: -0.7); | ||
color: vars.$disabled; | ||
|
||
&:hover { | ||
background-color: color.scale(vars.$textfield-bg, $lightness: 15%); | ||
} | ||
} | ||
|
||
@mixin text-field-input { | ||
outline: none; | ||
font-family: vars.$font; | ||
font-size: 1rem; | ||
font-weight: vars.$thin-font-weight; | ||
height: 2.8em; | ||
} | ||
|
||
@mixin button { | ||
font-family: vars.$font; | ||
font-weight: vars.$bold-font-weight; | ||
outline: none; | ||
display: flex; | ||
align-items: center; | ||
cursor: pointer; | ||
|
||
&::-moz-focus-inner { | ||
border: 0; | ||
} | ||
} |
Empty file.
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
Oops, something went wrong.