Skip to content
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

WIP: Feature: Add setting to ignore components #136

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion lib/edge/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import path from 'path'
import * as edge from 'edge.js'
import VerbatimTag from './VerbatimTag'

const viewData = {
devOnly: process.env.NODE_ENV !== 'production',
}
edge.registerViews(path.join(__dirname, './packages/shell-chrome/views'))
edge.tag(new VerbatimTag())

export function renderView(view, outputFilename, outputPath) {
let contents = edge.render(view)
let contents = edge.render(view, viewData)
let dir = outputPath || path.join(__dirname, './dist/chrome')

if (process.env.NODE_ENV === 'production') {
Expand Down
1 change: 0 additions & 1 deletion packages/shell-chrome/src/devtools/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default function devtools() {

themes: themes,

experimentalPanelEnabled: process.env.NODE_ENV !== 'production',
settingsPanelOpen: false,

get isLatest() {
Expand Down
5 changes: 2 additions & 3 deletions packages/shell-chrome/views/settings/index.edge
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@
</button>
<div
x-data="{

pages: [
{
name: 'Preferences',
enabled: true,
},
{
name: 'Experimental',
enabled: window.devtools().experimentalPanelEnabled,
enabled: {{ devOnly }},
}
],
].filter(p => p.enabled),
active: 'Preferences'
}"
class="flex space-x-4"
Expand Down
24 changes: 22 additions & 2 deletions packages/shell-chrome/views/settings/pages/preferences.edge
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<div x-show="active === 'Preferences'">
<div class="w-full border-b border-cool-gray-200 mb-4 pb-2">
<div class="w-full border-b border-cool-gray-200 mb-2 pb-2">
<h3 class="text-2xl font-light">Preferences</h3>
</div>
<div>Preferences content</div>
<div class="lg:grid grid-cols-3">
<div>
<h2 class="uppercase text-sm font-medium mb-3 text-cool-gray-500">Visibility</h2>
<div>
<label for="email" class="block text-sm font-medium text-gray-700">Hidden components</label>
<div class="mt-1">
<input
type="text"
autocomplete="off"
name="hide-component"
class="p-0.5 px-2 shadow-sm focus:ring-ice-500 focus:border-transparent block w-full sm:text-xs border-gray-300 rounded-md placeholder-cool-gray-400"
placeholder="[x-devtools-ignore]"
aria-describedby="hide-component-description"
/>
</div>
<p class="mt-1 text-xs text-gray-500" id="hide-component-description">
Hide components using the above selector.
</p>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion packages/simulator/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function injectPanel(containerNode) {
// this contains all sorts of CSS tags etc
containerNode.innerHTML = rawPanelHtml
// keep only the Alpine components in the panel
const panelAppHtml = Array.from(containerNode.querySelectorAll('[x-data]'))
const panelAppHtml = Array.from(containerNode.querySelectorAll('#devtools-container > [x-data]'))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking this will only work on the simulator. Will see what i can do. It's otherwise duplicating the settings page.

Copy link
Collaborator

@HugoDF HugoDF Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding data-testids to the panel "root" components, data-testid="panel-root" maybe?

Would have to be added to both

<div x-data x-show="false" class="preload">Devtools loading...</div>

and

<div id="app" class="h-full" x-cloak x-data="devtools()" x-init="init()" x-spread="devtoolsRootDirectives()">

Should keep the selectors simpler and it matches our use-case (we're selecting using the testid's for dev/testing purposes only)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now if you want to check it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

.map((el) => el.outerHTML)
.join('\n')

Expand Down