DEV: various improvements to devex on chat (#21612)

- Improves styleguide support
- Adds toggle color scheme to styleguide
- Adds properties mutators to styleguide
- Attempts to quit a session as soon as done with it in system specs, this should at least free resources faster
- Refactors fabricators to simplify them
- Adds more fabricators (uploads for example)
- Starts implementing components pattern in system specs
- Uses Chat::Message creator to create messages in system specs, this should help to have more real specs as the side effects should now happen
This commit is contained in:
Joffrey JAFFEUX
2023-05-17 17:49:52 +02:00
committed by GitHub
parent 4d0b997559
commit 60c67afba4
75 changed files with 1002 additions and 260 deletions

View File

@ -0,0 +1,3 @@
<div class="component">
{{yield}}
</div>

View File

@ -0,0 +1,3 @@
import Component from "@glimmer/component";
export default class StyleguideComponent extends Component {}

View File

@ -0,0 +1,5 @@
<table class="component-properties">
<tbody>
{{yield}}
</tbody>
</table>

View File

@ -0,0 +1,3 @@
import Component from "@glimmer/component";
export default class StyleguideControls extends Component {}

View File

@ -0,0 +1,6 @@
<tr class="component-properties__row">
<td class="component-properties__cell">{{@name}}</td>
<td class="component-properties__cell">
{{yield}}
</td>
</tr>

View File

@ -0,0 +1 @@
<DToggleSwitch @state={{@enabled}} {{on "click" @action}} />

View File

@ -0,0 +1,3 @@
import Component from "@glimmer/component";
export default class StyleguideControlsToggle extends Component {}

View File

@ -0,0 +1 @@
<DButton @action={{this.toggle}} class="toggle-color-mode">Toggle color</DButton>

View File

@ -0,0 +1,45 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { tracked } from "@glimmer/tracking";
const DARK = "dark";
const LIGHT = "light";
function colorSchemeOverride(type) {
const lightScheme = document.querySelector("link.light-scheme");
const darkScheme = document.querySelector("link.dark-scheme");
if (!lightScheme || !darkScheme) {
return;
}
switch (type) {
case DARK:
lightScheme.media = "none";
darkScheme.media = "all";
break;
case LIGHT:
lightScheme.media = "all";
darkScheme.media = "none";
break;
}
}
export default class ToggleColorMode extends Component {
@service keyValueStore;
@tracked colorSchemeOverride = this.default;
get default() {
return window.matchMedia("(prefers-color-scheme: dark)").matches
? DARK
: LIGHT;
}
@action
toggle() {
this.colorSchemeOverride = this.colorSchemeOverride === DARK ? LIGHT : DARK;
colorSchemeOverride(this.colorSchemeOverride);
}
}

View File

@ -1,5 +1,6 @@
<section class="styleguide">
<section class="styleguide-menu">
<ToggleColorMode />
{{#each this.categories as |c|}}
<ul>
<li class="styleguide-heading">{{i18n

View File

@ -73,6 +73,36 @@
.rendered {
width: 100%;
position: relative;
.component {
padding: 2rem;
border: 2px dotted var(--primary-low);
margin-bottom: 2rem;
}
.component-properties {
width: 100%;
&__cell {
padding: 0.5rem 0;
&:first-child {
width: 30%;
}
textarea,
input {
box-sizing: border-box;
margin: 0;
width: 100%;
}
textarea {
height: 100px;
}
}
}
}
margin-bottom: 2em;