diff --git a/.prettierrc.js b/.prettierrc.js index 3def2a11..f27575af 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -4,10 +4,4 @@ module.exports = { singleQuote: true, tabWidth: 4, trailingComma: 'all', - overrides: [ - { - files: '*.edge', - options: { parser: 'html' }, - }, - ], } diff --git a/cypress/integration/component.js b/cypress/integration/component.js index 0ef00697..ef4e21ae 100644 --- a/cypress/integration/component.js +++ b/cypress/integration/component.js @@ -133,6 +133,7 @@ it('should add/remove hover overlay on component mouseenter/leave', () => { }) cy.iframe('#target').find('[data-testid=hover-element]').should('not.exist') }) + it('should support selecting/unselecting a component', () => { cy.visit('/') @@ -217,3 +218,12 @@ it('should allow editing of booleans, numbers and strings', () => { cy.iframe('#target').contains('Str, type: "string", value: "devtools"') }) + +it('should display message with number of components watched', () => { + cy.visit('/') + .get('[data-testid=component-name]') + .should('have.length.above', 0) + .then((components) => { + cy.get('[data-testid=footer-line]').should('contain', `Watching ${components.length} components`) + }) +}) diff --git a/cypress/integration/load.js b/cypress/integration/load.js index 04c27796..32756589 100644 --- a/cypress/integration/load.js +++ b/cypress/integration/load.js @@ -14,9 +14,7 @@ it('should load devtools', () => { .should('equal', AlpineVersion) // Devtools initialised - cy.get('[data-testid=status-line]') - .should('have.attr', 'title', 'Latest Version') - .contains(`Alpine.js v${AlpineVersion} detected`) + cy.get('[data-testid=version-line]').should('have.attr', 'title', 'Latest Version').contains(`v${AlpineVersion}`) cy.get('[data-testid=component-name]').should('have.length.above', 0) cy.get('[data-testid=select-component-message]').should('have.text', 'Select a component to view') @@ -38,9 +36,7 @@ it('should load devtools when no components found', () => { .should('equal', AlpineVersion) // Devtools initialised - cy.get('[data-testid=status-line]') - .should('have.attr', 'title', 'Latest Version') - .contains(`Alpine.js v${AlpineVersion} detected`) + cy.get('[data-testid=version-line]').should('have.attr', 'title', 'Latest Version').contains(`v${AlpineVersion}`) cy.get('[data-testid=component-name]').should('have.length', 0) cy.get('[data-testid=no-components-message]').should('be.visible').should('contain.text', 'No components found') diff --git a/cypress/integration/version.js b/cypress/integration/version.js index b530a8e0..3419a5a3 100644 --- a/cypress/integration/version.js +++ b/cypress/integration/version.js @@ -23,10 +23,10 @@ it('should display link + message for undefined outdated Alpine version (pre 2.3 .window() .its('Alpine.version') .should('equal', AlpineVersion) - .get('[data-testid=status-line]') + .get('[data-testid=version-line]') .should('have.attr', 'title', `Latest Version: ${AlpineVersion}`) - .should('contain', 'Alpine.js { .window() .its('Alpine.version') .should('equal', AlpineVersion) - .get('[data-testid=status-line]') + .get('[data-testid=version-line]') .should('have.attr', 'title', `Latest Version: ${AlpineVersion}`) - .should('contain', 'Alpine.js v2.6.0 detected') - .get('a') + .should('contain', 'v2.6.0') + .get('[data-testid=version-line] a') .should('have.attr', 'href', 'https://github.com/alpinejs/alpine/releases') }) @@ -55,10 +55,10 @@ it('should display message for up to date version of Alpine.version', () => { .window() .its('Alpine.version') .should('equal', AlpineVersion) - .get('[data-testid=status-line]') + .get('[data-testid=version-line]') .should('have.attr', 'title', `Latest Version`) - .should('contain', `Alpine.js v${AlpineVersion} detected`) - .get('a') + .should('contain', `v${AlpineVersion}`) + .get('[data-testid=version-line] a') .should('have.attr', 'href', '#') }) @@ -71,10 +71,10 @@ it('should display message for future Alpine versions', () => { .window() .its('Alpine.version') .should('equal', AlpineVersion) - .get('[data-testid=status-line]') + .get('[data-testid=version-line]') .should('have.attr', 'title', `Latest Version`) - .should('contain', `Alpine.js v4.0.0 detected`) - .get('a') + .should('contain', 'v4.0.0') + .get('[data-testid=version-line] a') .should('have.attr', 'href', '#') }) @@ -99,9 +99,9 @@ it('should display message with latest Alpine version from npm registry', () => .its('Alpine.version') .should('equal', AlpineVersion) .wait('@registryRequest') - .get('[data-testid=status-line]') + .get('[data-testid=version-line]') .should('have.attr', 'title', `Latest Version: 5.0.0`) - .should('contain', `Alpine.js v4.0.0 detected`) - .get('a') + .should('contain', 'v4.0.0') + .get('[data-testid=version-line] a') .should('have.attr', 'href', 'https://github.com/alpinejs/alpine/releases') }) diff --git a/lib/edge/render.js b/lib/edge/render.js index 86760414..2606f039 100644 --- a/lib/edge/render.js +++ b/lib/edge/render.js @@ -3,11 +3,15 @@ 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') { diff --git a/package.json b/package.json index d2aef705..54a0aa49 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test": "jest", "cy:run": "cypress run", "cy:open": "cypress open", - "format": "prettier './{packages/**/,cypress/**/*,}*.{js,html,edge,css}' --write", + "format": "prettier './{packages/**/,cypress/**/*,}*.{js,html,css}' --write", "check:format": "prettier './{packages/**/,cypress/**/*,}*.{js,html,css}' -c", "prepackage": "npm run build", "package": "cd ./dist/chrome && zip -r ../alpine-devtools-$npm_package_version.zip . && rm -rf ../chrome" @@ -46,6 +46,6 @@ } }, "lint-staged": { - "*.{js,css,md,html,edge}": "prettier --write" + "*.{js,css,md,html}": "prettier --write" } } diff --git a/packages/shell-chrome/src/devtools/devtools.js b/packages/shell-chrome/src/devtools/devtools.js index 605e2d84..7058d17b 100644 --- a/packages/shell-chrome/src/devtools/devtools.js +++ b/packages/shell-chrome/src/devtools/devtools.js @@ -41,6 +41,7 @@ export default function devtools() { showTools: false, showTimeout: 1500, activeTheme: 'dark-header', + loadingText: 'Alpine.js tools loading', orientation: getOrientation(), split: null, @@ -50,6 +51,9 @@ export default function devtools() { settingsPanelEnabled: process.env.NODE_ENV !== 'production', settingsPanelOpen: false, + tabsEnabled: process.env.NODE_ENV !== 'production', + activeTab: 'components', + get isLatest() { if (!this.version || !this.latest) return null return isRequiredVersion(this.latest, this.version) @@ -60,11 +64,11 @@ export default function devtools() { }, get detected() { - if (!this.showTools) { - return 'Alpine.js tools loading' - } + return this.version ? `v${this.version}` : ' { if (!this.showTools) { fetchWithTimeout('https://registry.npmjs.com/alpinejs', { timeout: this.showTimeout }) @@ -114,14 +119,14 @@ export default function devtools() { } const key = this.isLandscape ? 'columnGutters' : 'rowGutters' - splitOptions[key] = [ - { - track: 1, - element: this.$refs.handle, - }, - ] - this.$nextTick(() => { + splitOptions[key] = [ + { + track: 1, + element: this.$refs.handle, + }, + ] + this.split = Split(splitOptions) }) }, diff --git a/packages/shell-chrome/views/_components/tab-link.edge b/packages/shell-chrome/views/_components/tab-link.edge new file mode 100644 index 00000000..f6d51a00 --- /dev/null +++ b/packages/shell-chrome/views/_components/tab-link.edge @@ -0,0 +1,13 @@ + + @!yield($slot.main) + + diff --git a/packages/shell-chrome/views/_partials/component.edge b/packages/shell-chrome/views/_partials/component.edge index 5c97a4d0..3a4d41c1 100644 --- a/packages/shell-chrome/views/_partials/component.edge +++ b/packages/shell-chrome/views/_partials/component.edge @@ -1,8 +1,8 @@ @verbatim + + +
+ + + + + + + + + + + +
+ diff --git a/packages/shell-chrome/views/_partials/header.edge b/packages/shell-chrome/views/_partials/header.edge index 0c3fe13d..7b4cfa74 100644 --- a/packages/shell-chrome/views/_partials/header.edge +++ b/packages/shell-chrome/views/_partials/header.edge @@ -3,7 +3,7 @@ 'bg-gray-100': !showTools, [theme['bg-header']]: showTools, }" - class="flex py-2 pl-3 pr-4 text-base leading-9 tracking-tight font-bold text-white border-b border-gray-300 transition duration-700 transition-colors ease-in-out sm:leading-10" + class="{{ devOnly ? '' : 'py-2' }} flex items-center h-15 pl-3 pr-1 xs:pr-3 text-base tracking-tight font-bold text-white border-b border-gray-300 transition duration-700 transition-colors ease-in-out" >
@@ -34,82 +34,78 @@ @verbatim
- +
@endverbatim
- + @endcomponent + + @endif diff --git a/packages/shell-chrome/views/_partials/tabs/components.edge b/packages/shell-chrome/views/_partials/tabs/components.edge new file mode 100644 index 00000000..9a6f4811 --- /dev/null +++ b/packages/shell-chrome/views/_partials/tabs/components.edge @@ -0,0 +1,76 @@ +
+ +
+ +
+ +
+
+ + + @include('_partials.handle') + + +
+ + + + +
+ +
+
+
diff --git a/packages/shell-chrome/views/panel.edge b/packages/shell-chrome/views/panel.edge index 0c580e96..05b1cc98 100644 --- a/packages/shell-chrome/views/panel.edge +++ b/packages/shell-chrome/views/panel.edge @@ -19,77 +19,25 @@
@include('_partials.header') -
- -
- -
- +
+ @include('_partials.tabs.components') +
+ + @if(devOnly) +
+
+ Events Tab
- - @include('_partials.handle') - - -
- - - - -
- +
+
+ Warnings Tab
-
+ @endif + + @include('_partials.footer') @include('_partials.settings')
diff --git a/tailwind.config.js b/tailwind.config.js index ecc7f113..04fbd476 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -67,6 +67,12 @@ module.exports = { zIndex: { max: '2147483647', }, + borderWidth: { + 3: '3px', + }, + screens: { + xs: '560px', + }, }, }, variants: {