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

es-progression checkpoint not clickable option #342

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ export namespace Components {
* The current active location.
*/
"location": string;
/**
* The current active location.
*/
"readonly"?: boolean;
}
/**
* Wraps a [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) to allow tracking `DOMRect` dimensions
Expand Down Expand Up @@ -1577,6 +1581,10 @@ declare namespace LocalJSX {
* Emitted when a checkpoint is clicked.
*/
"onProgressionRequest"?: (event: EsProgressionCustomEvent<string>) => void;
/**
* The current active location.
*/
"readonly"?: boolean;
}
/**
* Wraps a [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) to allow tracking `DOMRect` dimensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ button {
align-items: center;
background-color: transparent;
font: inherit;
cursor: pointer;
outline: none;
color: var(--color-text);
position: relative;
Expand All @@ -44,11 +43,15 @@ button {
transition-timing-function: ease;
}

&:hover,
&:focus {
& .center {
opacity: 1;
transform: scale(0.5);
&:not(.readonly) {
cursor: pointer;

&:hover,
&:focus {
& .center {
opacity: 1;
transform: scale(0.5);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Checkpoint } from './types';
export class Counter {
@State() location1: string = '1-1';
@State() location2: string = '2-1';
@State() location3: string = '3-1';

render() {
return (
Expand Down Expand Up @@ -51,6 +52,16 @@ export class Counter {
}}
/>
</div>
<h1>Unclickable checkpoints</h1>
<div style={{ display: 'flex', gap: '20px' }}>
<es-progression
checkpoints={this.world3}
location={this.location3}
onProgressionRequest={(e) => {
this.location3 = e.detail;
}}
/>
</div>
</Host>
);
}
Expand Down Expand Up @@ -93,6 +104,7 @@ export class Counter {
case 'complete':
return [ICON_NAMESPACE, 'check'];
}
true;
},
},
{
Expand All @@ -119,6 +131,28 @@ export class Counter {
{
id: '2-4',
title: 'Castle',
disabled: true,
},
];

private readonly world3: Checkpoint[] = [
{
id: '3-1',
title: 'Overworld',
readonly: true,
},
{
id: '3-2',
title: 'Underground',
},
{
id: '3-3',
title: 'Athletic',
readonly: true,
},
{
id: '3-4',
title: 'Castle',
},
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class Progression {
@Prop() checkpoints!: Checkpoint[];
/** The current active location. */
@Prop() location!: string;
/** The current active location. */
Nurmaan marked this conversation as resolved.
Show resolved Hide resolved
@Prop() readonly?: boolean;
/** Set custom colors for all checkpoints */
@Prop() colors?: Partial<Record<CheckpointState, string>>;
/** Set custom icons for all checkpoints */
Expand Down Expand Up @@ -69,6 +71,7 @@ export class Progression {
id,
title,
disabled = false,
readonly = this.readonly ?? false,
color,
inactiveColor,
icon,
Expand All @@ -82,10 +85,15 @@ export class Progression {
key={id}
type={'button'}
part={`checkpoint ${state}`}
class={state}
class={{
readonly,
[state]: true,
}}
disabled={disabled}
tabindex={state === 'active' ? -1 : 0}
onClick={() => this.progressionRequest.emit(id)}
onClick={() =>
readonly ? null : this.progressionRequest.emit(id)
}
style={{
'--checkpoint-color': color,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default () => (
| `colors` | -- | Set custom colors for all checkpoints | `undefined \| { active?: string \| undefined; complete?: string \| undefined; inactive?: string \| undefined; }` | `undefined` |
| `icons` | -- | Set custom icons for all checkpoints | `undefined \| { active?: IconDescription \| undefined; complete?: IconDescription \| undefined; inactive?: IconDescription \| undefined; }` | `undefined` |
| `location` _(required)_ | `location` | The current active location. | `string` | `undefined` |
| `readonly` | `readonly` | The current active location. | `boolean \| undefined` | `undefined` |


## Events
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/components/es-progression/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Checkpoint {
id: string;
title: string;
disabled?: true;
readonly?: boolean;
color?: (state: CheckpointState) => string | undefined;
icon?: (state: CheckpointState) => IconDescription | undefined;
}