* Fix .no-reduce-motion missing from graphs spinner, and not being honored
* Begin migration from protobuf.js -> protobuf-es
Motivation:
- Protobuf-es has a nicer API: messages are represented as classes, and
fields which should exist are not marked as nullable.
- As it uses modules, only the proto messages we actually use get included
in our bundle output. Protobuf.js put everything in a namespace, which
prevented tree-shaking, and made it awkward to access inner messages.
- ./run after touching a proto file drops from about 8s to 6s on my machine. The tradeoff
is slower decoding/encoding (#2043), but that was mainly a concern for the
graphs page, and was unblocked by
37151213cd
Approach/notes:
- We generate the new protobuf-es interface in addition to existing
protobuf.js interface, so we can migrate a module at a time, starting
with the graphs module.
- rslib:proto now generates RPC methods for TS in addition to the Python
interface. The input-arg-unrolling behaviour of the Python generation is
not required here, as we declare the input arg as a PlainMessage<T>, which
marks it as requiring all fields to be provided.
- i64 is represented as bigint in protobuf-es. We were using a patch to
protobuf.js to get it to output Javascript numbers instead of long.js
types, but now that our supported browser versions support bigint, it's
probably worth biting the bullet and migrating to bigint use. Our IDs
fit comfortably within MAX_SAFE_INTEGER, but that may not hold for future
fields we add.
- Oneofs are handled differently in protobuf-es, and are going to need
some refactoring.
Other notable changes:
- Added a --mkdir arg to our build runner, so we can create a dir easily
during the build on Windows.
- Simplified the preference handling code, by wrapping the preferences
in an outer store, instead of a separate store for each individual
preference. This means a change to one preference will trigger a redraw
of all components that depend on the preference store, but the redrawing
is cheap after moving the data processing to Rust, and it makes the code
easier to follow.
- Drop async(Reactive).ts in favour of more explicit handling with await
blocks/updating.
- Renamed add_inputs_to_group() -> add_dependency(), and fixed it not adding
dependencies to parent groups. Renamed add() -> add_action() for clarity.
* Remove a couple of unused proto imports
* Migrate card info
* Migrate congrats, image occlusion, and tag editor
+ Fix imports for multi-word proto files.
* Migrate change-notetype
* Migrate deck options
* Bump target to es2020; simplify ts lib list
Have used caniuse.com to confirm Chromium 77, iOS 14.5 and the Chrome
on Android support the full es2017-es2020 features.
* Migrate import-csv
* Migrate i18n and fix missing output types in .js
* Migrate custom scheduling, and remove protobuf.js
To mostly maintain our old API contract, we make use of protobuf-es's
ability to convert to JSON, which follows the same format as protobuf.js
did. It doesn't cover all case: users who were previously changing the
variant of a type will need to update their code, as assigning to a new
variant no longer automatically removes the old one, which will cause an
error when we try to convert back from JSON. But I suspect the large majority
of users are adjusting the current variant rather than creating a new one,
and this saves us having to write proxy wrappers, so it seems like a
reasonable compromise.
One other change I made at the same time was to rename value->kind for
the oneofs in our custom study protos, as 'value' was easily confused
with the 'case/value' output that protobuf-es has.
With protobuf.js codegen removed, touching a proto file and invoking
./run drops from about 8s to 6s.
This closes#2043.
* Allow tree-shaking on protobuf types
* Display backend error messages in our ts alert()
* Make sourcemap generation opt-in for ts-run
Considerably slows down build, and not used most of the time.
* Fix double scrollbars in deck options
* Remove !important
Future pages may want to override overflow-x (?) and it doesn't seem to change anything for now.
* Allow the body to expand vertically in the import CSV page
* Create widget gallery dialog
* Add WidgetGallery to debug dialog
* Use enum for its intended purpose
* Rename "reduced-motion" to "reduce-motion"
* Add another border-radius value
and make former large radius a bit smaller.
* Revamp preferences, add minimalist mode
Also:
- create additional and missing widget styles and tweak existing ones
- use single profile entry to set widget styles and reduce choices to Anki and Native
* Indent QTabBar style definitions
* Add missing styles for QPushButton states
* Fix QTableView background
* Remove unused layout from Preferences
* Fix QTabView focused tab style
* Highlight QCheckBox and QRadioButton when focused
* Fix toolbar styles
* Reorder preferences
* Add setting to hide bottom toolbar
* Move toolbar settings above minimalist modes
* Remove unused lines
* Implement proper full-screen mode
* Sort imports
* Tweak deck overview appearance in minimalist mode
* Undo TitledContainer changes
since nobody asked for that
* Remove dynamic toolbar background from minimalist mode
* Tweak buttons in minimalist mode
* Fix some issues
* Reduce theme check interval to 5s on Linux
* Increase hide timer interval to 2s
* Collapse toolbars with slight delay when moving to review state
This should ensure the bottom toolbar collapses too.
* Allow users to make hiding exclusive to full screen
* Rename full screen option
* Fix hide mode dropdown ignoring checkbox state on startup
* Fix typing issue
* Refine background image handling
Giving the toolbar body the main webview height ensures background-size: cover behaves exactly the same.
To prevent an override of other background properties, users are advised to only set background-images via the background-image property, not the background shorthand.
* Fix top toolbar getting huge when switching modes
The issue was caused by the min-height hack to align the background images. A call to web.adjustHeightToFit would set the toolbar to the same height as the main webview, as the function makes use of document.offsetHeight.
* Prevent scrollbar from appearing on bottom toolbar resize
* Cleanup
* Put review tab before editing; fix some tab orders
* Rename 'network' to 'syncing'
* Fix bottom toolbar disappearing on UI > 100
* Improve Preferences layout by adding vertical spacers to the bottom
also make the hiding of video_driver and its label more obvious in preferences.py.
* Fix bottom toolbar animating on startup
Also fix bottom toolbar not appearing when unchecking hide mode in reviewer.
* Hide/Show menubar in fullscreen mode along with toolbar
* Attempt to fix broken native theme on macOS
* Format
* Improve native theme on other systems by not forcing palette
with the caveat that theme switching can get weird.
* Fix theme switching in native style
* Remove redundant condition
* Add back check for Qt5 to prevent theme issues
* Add check for macOS before setting fusion theme
* Do not force scrollbar styles on macOS
* Remove all of that crazy theme logic
* Use canvas instead of button-bg for ColorRole.Button
* Make sure Anki style is always based on Fusion
otherwise we can't guarantee the same look on all systems.
* Explicitly apply default style when Anki style is not selected
This should fix the style not switching back after it was selected.
* Remove reduncant default_palette
* Revert 8af4c1cc2
On Mac with native theme, both Qt5 and Qt6 look correct already. On
the Anki theme, without this change, we get the fusion-style scrollbars
instead of the rounded ones.
* Rename AnkiStyles enum to WidgetStyle
* Fix theme switching shades on same theme
* Format
* Remove unused placeholderText
that caused an error when opening the widget gallery on Qt5.
* Check for full screen windowState using bitwise operator
to prevent error in Qt5.
Credit: https://stackoverflow.com/a/65425151
* Hide style option on Windows
also exclude native option from dropdown just in case.
* Format
* Minor naming tweak
* Give webviews a slide-in animation
if reduced motion isn't set.
* Auto-hide toolbar in review mode
moving the mouse above the main webview expands the toolbar. When the mouse leaves the toolbar, it will collapse after a delay of 2s.
* Save some space on bottom toolbars
* Use props for all hard-coded transition durations
and decrease most commonly used duration (200ms) to 150ms.
* Move auto-hide logic into ToolbarWebView
and handle auto-hide specific events in the respective webview subclasses.
* Fix typing issues
* Fix flickering issue
* Add auto_hide_toolbar opt-in to preferences
* Rename hide_toolbar to collapse_toolbar
to better describe the dock-like behaviour.
* Rename setting to minimize_distractions
* Reduce calls to pm in eventFilter
* Run formatter
* Revert setting title to something more specific
* Increase default animation time to 180ms
* Inset toolbar in review mode
when auto-hide is not enabled.
* Use card background on toolbar and add glass effect
* Use flatten/elevate over inset/outset
* Use flatten/elevate over inset/outset
* Update toolbar.py
* Fix toolbar background delay
* Tweak styles
* Use "collapse" instead of "auto-hide"
* Fix background misalignment in collapse mode
* Do not collapse toolbar when pointer is outside MainWebView
* Reduce hide_timer interval to 1000ms
* Use CSS to hide toolbar instead of setting webview height
* Add guard to prevent backdrop-filter: blur on Qt 5.14
* Apply transition to body instead of toolbar
to not complicate things for #2301.
* Fix Qt 5.14 and apply guard globally
* Fix background image scaling difference
* Tweak preference wording (dae)
* Replace border-with inset shadow on button hover
* Align gradient-end with base color for primary buttons too
to achieve a more natural hover effect.
* Fix QMenu item not having different color on hover
due to the color changes in #2220.
* Remove strong border on pressed Qt widgets
* Make button gradient more subtle
by changing gradient-start on hover instead of gradient-end.
* Apply QPushButton style to QSpinBox buttons
* Improve margin of QComboBox arrow
* Make button-bg same color as button-gradient-end
This makes the hover gradient more subtle.
* Give deck browser table an elevated container look
* Tweak colors of elevated containers (e.g. in deck options)
* Prepare editor fields for custom backgrounds
* Tweak field margin and add explanatory comment
(for upgrading users, please see the notes at the bottom)
Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.
For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).
Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.
These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:
- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.
I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.
The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.
This new build system should result in faster builds in some cases:
- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.
As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.
Some other changes of note:
- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.
If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:
- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
* Reduce font size of answer button indicators
* Increase padding of browser rows with ResizeToContents on vertical header
* Remove 0.8 scale factor for dropdown item font-size
* Remove font-size prop entirely from DropdownItem
* Revert "Remove font-size prop entirely from DropdownItem"
This reverts commit bb0a158f96.
* Remove hard-coded Python font sizes
* Move font size and scrollbar into _root-vars.scss
* Revert editor size variable to 1.6
* Fix icon alignment
* Fix checkbox alignment for dropdown items
* Remove unused classes from Tag.svelte
* Revert "Increase padding of browser rows with ResizeToContents on vertical header"
This reverts commit 77bfc854ba.
* Remove option to set font size of browser entries
* Add setting for browser row padding to preferences
* Revert "Add setting for browser row padding to preferences"
This reverts commit 75c59da65a.
* Revert "Remove option to set font size of browser entries"
This reverts commit a543783d8e.
* Use button gradient only on hover
* Apply hover effect to main window buttons
* Apply arbitrary change to force recreation of colors.py
* Undo arbitrary change to fix props not being created
* Remember that the comments are used for regex matching
* Yet another try
* Revert "Yet another try"
This reverts commit eaef4805c1.
* Update _root-vars.scss
* Include base styles in graphs-base.scss
This includes the custom scrollbar styles, which were missing on the stats page.
* Set responsive grid layout on GraphsPage, use TitledContainer component
+ use global button style, tweak input appearance and other small changes
* Improve margins on GraphsPage
* Prevent multiple inclusion of variables in CSS files
* Use dict instead of tuple for variables
* Add comments to variables
* Improve appearance of main window
* Tweak main window styles
* Use json.dumps over pprint.format
* Make study button primary
* Improve header margin
* Make bottom toolbar slimmer
* Make congrats page more balanced
* Fix type issue
* Replace day/night with light/dark
* Exclude top-level-drag-row from hover effect
* Create dataclass for variables
* Run formatter
* Apply CSS variables from Python side
Why go full-circle with the Sass variables? This way we only need one interface for add-on authors to interact with. It also makes it easier for us to apply additional themes in the future.
* Fix typing
* Fix rgba values in Qt
* Darken button background
* Fix palette not being applied in light theme
For some odd reason this problem arose much later than #2016.
* Tweak default button look
* Reformat
* Apply CSS vars to ts pages
* Include elevation in button_mixins_lib
* Cast opacity to int
* Add some margin to studiedToday info
* Tweak light theme button gradient
* Tweak highlight-bg for light theme
* Add back default button color
as it made the browser sidebar tool icons dark in light theme.
* Reformat
* Tweak light theme buttons once more
Sorry for the back-and-forth. Sass only compiles when there are changes in user files, not when I only change the vars.
* Fix bottom toolbar button indicators
* Make buttons more clicky
* Fix button padding
* Handle macOS separately again
* Decrease elevation effect for main window buttons to 1
* Imitate box-shadow for Qt elements
* Adjust shadow vars
* Adjust primary border color
because the save button in the deck options had a lighter color than its background gradient.
* Boost box-shadow color of primary buttons
* Format
* Adjust Qt box-shadow imitation and shadow colors
* Use more subtle default shadow color
* Add some more padding to top toolbar
* Revert "Apply CSS vars to ts pages"
This reverts commit 5d8e7f6b7f.
* Revert "Apply CSS variables from Python side"
This reverts commit 87db774412.
* Better match the standard macOS buttons
In the dark theme the standard color is a lighter grey, but at least
the size/shape is similar again.
This doesn't work for the editor buttons.
* Reduce the top margin of the congrats screen
* Fix illegible buttons when changing theme on macOS; match dark button style
* Move up MathjaxOverlay to be initialized only once
* Move ImageOverlay to NoteEditor root
* Move Symbols Overlay to NoteEditor root
* Refactor image overlay to not require second mutation observer
* Use elevation + overflow:hidden in Editorfield
* Make it possible to show input next to each other again
* Set handle background color to code bg
* Make Collapsible unmount the component
* Simplify how decorated elements are mounted
* Set RichTextInput background to frame-bg again
* Strip out FocusTrap code
* Revert "Make Collapsible unmount the component"
This reverts commit 52722065ea.
* Allow clicking on label container to unfocus field
* Fix mathjax overlay resetting too its api too soon
* Allow scrolling on overlays
* Set focus-border border-color in focused field
* Fix background color of fields
* Add back grid-gap
removed it during merge to see if margin-top would behave any differently - which is not the case.
* Fix double border issue within Collapsible.svelte
* Format
* Edit appearance of focused fields a bit
* Remove unused properties
* Include elevation in button_mixins_lib
* Give label-container a background color
Co-authored-by: Henrik Giesel <hengiesel@gmail.com>
* Give QMenu cursor: pointer
* Darken border colors in dark theme
* Refactor cursor: pointer event filter
* Add QMenu stylesheet
* Remove min-width for QMenu item
* Add QMenuBar styles
with increased height for touchscreen users and more visible highlight color.
* Fix type
* Revert "Add QMenuBar styles"
This reverts commit 6ae405a073.
* Remove strong border from QMenu checkbox style
* Keep highlight color consistent
* Adjust highlight-bg
* Increase horizontal padding and adjust checkbox margin
* Introduce border-faint var and make default border brighter in dark mode
* Fix 1px move on hover and make highlight color more subtle
* Remove win10 styles
because the properties are set in the other stylesheets anyway.
* Fix bottom border of QMenuBar not showing underneath entries
* Remove unused import
* Make border-faint one shade darker in light theme
* Make tags editor resizable using Henrik's components
All credit for the components goes to Henrik. I just tweaked the design a bit and implemented them in NoteEditor.
Co-Authored-By: Henrik Giesel <hengiesel@gmail.com>
* Remove PaneContent padding
Co-Authored-By: Henrik Giesel <hengiesel@gmail.com>
* Add responsive box-shadows on scroll/resize
only shown when content overflows in the respective direction.
* Remove comment
* Fix overflow calculations and shadow mix-up
This happened when I switched from using scrolledToX to overflowX booleans.
* Simplify overflow calculations
* Make drag handles 0 height/width
The remaining height requirement comes from a margin set on NoteEditor.
* Run eslint on components
* Split editor into three panes: Toolbar, Fields, Tags
* Remove upper split for now
to unblock 2.1.55 beta
* Move panes.scss to sass folder
* Use single type for resizable panes
* Implement collapsed state toggled with click on resizer
* Add button to uncollapse tags pane and focus input
* Add indicator for # of tags
* Use dbclick to prevent interference with resize state
* Add utility functions for expand/collapse
* Meddle around with types and formatting
* Fix collapsed state being forgotten on second browser open (dae)
* Fix typecheck (dae)
Our tooling generates .d.ts files from the Svelte files, but it doesn't
expect variables to be exported. By changing them into functions, they
get included in .bazel/bin/ts/components/Pane.svelte.d.ts
* Remove an unnecessary bridgeCommand (dae)
* Fix the bottom of tags getting cut off (dae)
Not sure why offsetHeight is inaccurate in this case.
* Add missing header (dae)
Co-authored-by: Henrik Giesel <hengiesel@gmail.com>
* Create _input-mixins.scss
* Use button-mixins on more elements
* Replace <select> tag with custom Select component
* Fix RevertButton causing cursor: pointer when hidden
* Increase SaveButton chevron width
* Hide floating component box-shadow when inactive
* Rework SpinBox and move it into components
* Run eslint and prettier
* Remove leftover options prop
* Pass disabled array to EnumSelector again
* Update MapperRow.svelte
* Darken QHeaderView border color
Slipping this in without an extra PR.
* Adjust disabled color, border and cursor
* Remove redundant icon definition from stylesheets
* Fix deck options initial config
* Fix z-index issues in change notetype screen
It might be best to handle z-index locally in each user component instead of hard-coded component values.
* Give web SpinBox a horizontal design
* Give QRadioButton the same treatment as QCheckBox in #2079
* Fix unused CSS selector warning with base button-mixin
* Remove redundant import
* Fix deck options save button
* Delete input-mixins and remove unused down-arrow
* Run eslint on change-notetype
* Run eslint on components
* Fix custom scrollbar not showing
* Move body selector out of scrollbar mixin
* Apply custom scrollbar to child elements too
* Remove some duplicate definitions
* Run prettier
* Fix create_vars_from_map not creating vars with default definition
* Add white and black to vars
* Replace some hard-coded SVGs with mdi equivalents
* Implement function to dynamically adjust SVG icon color
* Use new svg function to make Qt stylesheet icons respond to theme changes
* Use svg function for sidebar tool icons
* Create copy for each new color instead of modifying source file
* Fix check fails
* Add custom checkbox style for #2079
* Add example of how to generate svgs during build (dae)
* Create arbitrary color variants for each icon with Bazel
* Remove unused label (dae)
* Use cursor: pointer on QCheckBoxes too and exclude disabled widgets
* Left-align all QCheckBoxes to make hover-area and clickable area the same
Altough the clickable area has always been restricted to the label, the widget itself stretched all the way. This became a problem with the new cursor-pointer for checkboxes.
* Remove Switch duplicate from deck-options
* Add cursor: pointer to Switch and RevertButton
* Add cursor: pointer to bottom toolbar buttons
* Add cursor: pointer to gears
* Add cursor: pointer to radio and checkbox inputs of graphs page
* Improve button appearance in stats screen
* Add cursor: pointer to QTabBar and QToolButton
* Add cursor: pointer to non-editable QComboBox
* Center settings-will-take-effect-after notice in preferences screen
* Use public without_qt5_compat_wrapper() function
* Run prettier
* Make several colors more faint
* Move selection-color definition out of table.py and adjust colors
* Use functions for repetitive border-gradient definitions
* Tweak QTableView and QScrollBar styles
* Use mdi icon for Qt drag handles and adjust padding in browser.ui
* Apply appropriate drag-handle icon depending on orientation
* Fix formatting
* Remove unused import
* Add right margin to browser layout
* Apply splitter styling on macOS as well (dae)
+ Remove the styling from sliders, as it was presumably not intentional.
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456, reversing
changes made to 6bb45355d1.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes#2054
* Add animation toggle to preferences
and move settings affecting appearance together.
* Add class to body if animations unchecked
* Fix formatting in preferences.ftl
* Update duration(height) function for Collapsible transition
and add explanation.
* Fix formatting
* Increase duration baseline to 10 and decrease factor to 20
* Restore initial layout and rename option to "Reduce motion"
* Move checkboxes together and fix tab order (dae)
+ Remove separation of UI size
* Adjust size of legacy buttons
* Revert "Adjust size of legacy buttons"
This reverts commit fb888fe1db.
* Remove unused function from #1476
* Use outline version for tag icon
* Add chevron icons
* Remove code icons, keep one pin icon version
* Add code-bg color
* Redesign fields
* Remove unused import
* Fix imports
* Move PlainTextBadge between editing inputs
where it belongs :)
* Make whole separator line clickable
* Fix transition
and format
* Don't show toggle when field is collapsed
* Show toggle only on hover
for mobile I'd like to implement a swipe mechanism.
* Use tweened SVG for triangle instead of CSS hack
* Implement more obvious HTML toggle on bottom right
* Reduce field height by a few pixels
* Reduce field height by two pixels
* Show HTML toggle when PlainTextInput is active, regardless of hover/focus
* Remove RichTextBadge.svelte
* Create separate collapsed field state
this means users can collapse fields with the HTML editor open and it will stay open when the field is expanded again.
* Add slide out animation to EditingArea, RichTextInput and PlainTextInput
only for collapsing, because it is choppy on expansion (common issue with Svelte transitions).
* Fix aliasing issue on focused field corners
* Make StickyBadge feel more responsive
* Move StickyBadge closer to field border
* Adjust field gutter/margins
* Make LabelContainer sticky
to make field operations accessible on fields with a lot of content.
* Add back html icons, remove visual editor icons
* Revert "Add code-bg color"
This reverts commit 4200f35419.
* Add rich text icon, remove strikethrough code icon
* Revert PlainTextBadge to original position
* Adjust margins in FieldState
* Rename PlainTextBadge to SecondaryInputBadge
in preparation for #1987
* Run eslint and prettier
* Make whole LabelContainer clickable area for collapse/expand
* Revert "Add slide out animation to EditingArea, RichTextInput and PlainTextInput"
This reverts commit 9a2b3410d0.
* Fix error on collapse/expansion
this was caused by the {#if} blocks, which resulted in the deletion of original EditingAreas.
* Refocus when toggling chevron and secondary input badge
* Revert "Revert "Add code-bg color""
This reverts commit 1cfd3bda65.
* Use single rotating chevron icon and make it RTL-compatible
* Remove redundant CSS transition rule
* Introduce animated Collapsible component and fix refocus on toggle
* Do not try to force repaint, as it is not required
* Remove RTL store from LabelContainer
the direction is already applied globally.
* Collapse secondary input with field
* Add focusedField to NoteEditorAPI
* Replace :global CSS selector with class .visible
thus removing the assumption that the component is used inside an EditorField.
https://github.com/ankitects/anki/pull/2002#discussion_r944876448
* Use named function syntax instead of function expressions
* Add explanation comment
* Remove unnecessary :bind directive
* Create CollapseBadge component
* Move :global selector into .plain-text-input
* Add comment explaining box-shadow pseudo-element
* Move Collapsible from EditingArea, PlainTextInput and RichTextInput into user components
* Rename SecondaryInputBadge to PlainTextBadge and remove generalization logic
I kept the rich text icon inside icons.ts for future use.
* Sort imports
* Fix background-color for duplicates not showing
with yet another pseudo-element :)
The pseudo-element that covers up field borders on scroll caused this issue. Fighting fire with fire here.
* Increase size of plain text toggle to original value again
This makes the clickable area a bit bigger and looks slightly more consistent with StickyBadge.
* Scrap pseudo-element mess in LabelContainer and tackle the actual issue
* Add class .visible to StickyBadge too
This introduces a peculiar bug: The active prop of StickyBadge resets to false when the mouse leaves the field - regardless of the actual back-end value.
* Fix sticky badge resetting on mouseleave/blur
* Apply overflow: hidden only during transition
fixes MathJax handle getting cut off by fields
* Remove unused variable
* Fix visual bug caused by overflow:hidden not applying in time
I tried several asynchronous approaches, but they all caused issues: either they prevented the CSS transition or they made field inputs lose focus.
In the end I resorted to direct, synchronous DOM-manipulation and added an explanatory comment.
* Decrease Collapsible load time by blocking first transition
I noticed the sliding animation has a hefty performance impact when a large number of fields is loaded simultaneously.
Blocking the first transition (which isn't even visible) results in a big boost in load time.
* Replace usages of gap with margins for children
* Revert unnecessary removal of grid-gap definition
* Correct comments about flex-gap property
mistook that for grid-gap.
* Resolve style issues
* Add minimum targets to gap comment
Co-authored-by: Henrik Giesel <hengiesel@gmail.com>
* Remove overscroll-behavior: none for * (all elements)
* Revert "Remove overscroll-behavior: none for * (all elements)"
This reverts commit 189358908c.
* Use body instead of *, but keep CSS rule
* Unify two CSS rules
* Add crate csv
* Add start of csv importing on backend
* Add Menomosyne serializer
* Add csv and json importing on backend
* Add plaintext importing on frontend
* Add csv metadata extraction on backend
* Add csv importing with GUI
* Fix missing dfa file in build
Added compile_data_attr, then re-ran cargo/update.py.
* Don't use doubly buffered reader in csv
* Escape HTML entities if CSV is not HTML
Also use name 'is_html' consistently.
* Use decimal number as foreign ease (like '2.5')
* ForeignCard.ivl → ForeignCard.interval
* Only allow fixed set of CSV delimiters
* Map timestamp of ForeignCard to native due time
* Don't trim CSV records
* Document use of empty strings for defaults
* Avoid creating CardGenContexts for every note
This requires CardGenContext to be generic, so it works both with an
owned and borrowed notetype.
* Show all accepted file types in import file picker
* Add import_json_file()
* factor → ease_factor
* delimter_from_value → delimiter_from_value
* Map columns to fields, not the other way around
* Fallback to current config for csv metadata
* Add start of new import csv screen
* Temporary fix for compilation issue on Linux/Mac
* Disable jest bazel action for import-csv
Jest fails with an error code if no tests are available, but this would
not be noticable on Windows as Jest is not run there.
* Fix field mapping issue
* Revert "Temporary fix for compilation issue on Linux/Mac"
This reverts commit 21f8a26140.
* Add HtmlSwitch and move Switch to components
* Fix spacing and make selectors consistent
* Fix shortcut tooltip
* Place import button at the top with path
* Fix meta column indices
* Remove NotetypeForString
* Fix queue and type of foreign cards
* Support different dupe resolution strategies
* Allow dupe resolution selection when importing CSV
* Test import of unnormalized text
Close #1863.
* Fix logging of foreign notes
* Implement CSV exports
* Use db_scalar() in notes_table_len()
* Rework CSV metadata
- Notetypes and decks are either defined by a global id or by a column.
- If a notetype id is provided, its field map must also be specified.
- If a notetype column is provided, fields are now mapped by index
instead of name at import time. So the first non-meta column is used for
the first field of every note, regardless of notetype. This makes
importing easier and should improve compatiblity with files without a
notetype column.
- Ensure first field can be mapped to a column.
- Meta columns must be defined as `#[meta name]:[column index]` instead
of in the `#columns` tag.
- Column labels contain the raw names defined by the file and must be
prettified by the frontend.
* Adjust frontend to new backend column mapping
* Add force flags for is_html and delimiter
* Detect if CSV is HTML by field content
* Update dupe resolution labels
* Simplify selectors
* Fix coalescence of oneofs in TS
* Disable meta columns from selection
Plus a lot of refactoring.
* Make import button stick to the bottom
* Write delimiter and html flag into csv
* Refetch field map after notetype change
* Fix log labels for csv import
* Log notes whose deck/notetype was missing
* Fix hiding of empty log queues
* Implement adding tags to all notes of a csv
* Fix dupe resolution not being set in log
* Implement adding tags to updated notes of a csv
* Check first note field is not empty
* Temporary fix for build on Linux/Mac
* Fix inverted html check (dae)
* Remove unused ftl string
* Delimiter → Separator
* Remove commented-out line
* Don't accept .json files
* Tweak tag ftl strings
* Remove redundant blur call
* Strip sound and add spaces in csv export
* Export HTML by default
* Fix unset deck in Mnemosyne import
Also accept both numbers and strings for notetypes and decks in JSON.
* Make DupeResolution::Update the default
* Fix missing dot in extension
* Make column indices 1-based
* Remove StickContainer from TagEditor
Fixes line breaking, border and z index on ImportCsvPage.
* Assign different key combos to tag editors
* Log all updated duplicates
Add a log field for the true number of found notes.
* Show identical notes as skipped
* Split tag-editor into separate ts module (dae)
* Add progress for CSV export
* Add progress for text import
* Tidy-ups after tag-editor split (dae)
- import-csv no longer depends on editor
- remove some commented lines
Issue was introduced in 7922f18296
when the styling was moved into base.scss. From what I can tell, there
are two locations where the current styling is required:
- the editor, to ensure the tags are shown at the bottom
- the change notetype screen, which requires this styling for a sticky
bar at top
I'm no CSS guru, so if someone thinks this could be solved in a better
way, please submit a follow-up PR.
Closes#1782
* Implement a first version of WithFloating and Portal
* Add outside slot for Portal
* Execute computePosition from WithFloating
* Set up a first example of new WithFloating with the Latex menu
* Use autoUpdate in WithFloating
* Create sveltelib/position
* Add event-store
* Use event-store in close-on-click
* Implement subscribeToUpdates
* Introduce sass/elevation
* Split close-on-click to closing-click and subscribe-trigger
* Have closing-* stores return a symbol
- This way they act more of an EventEmitter than a store
* Allow passing show store
* Remove styling on float on updatePosition removal
* Implement a nice border for dropdowns
* Apply different border and box-shadow to Popover in dark/light theme
* Fix Ctrl+Shift+T not working
* Satisfy formatters and tests
* Add copyright header
* move copyright header to top (dae)
* Show buried until daily limits in overview screen
This explains differences between the counts shown in the deck tree and
those shown in the overview screen.
Closes#1633.
* interday learning cards can be buried too (dae)
* add 'buried' tooltip to bury counts; generate row in helper fn (dae)
* Use grey for buried counts
* Fix button focus highlight on Windows
* Use none instead of none for outline and box-shadow
* Unnest selectors in reviewer-bottom
Co-authored-by: Henrik Giesel <hengiesel@gmail.com>