- Simplify alternatives to run the script.
- Change style of code parts to be easier to the eye:
- Use the same font size as other texts in body.
- Add vertical padding.
- Align the contents (the code, copy button and dollar sign) in the
middle.
- Align information icon to center of context next to it.
- Fix minor typos and punctations.
- Refactor instruction list to be more generic to able to be used by
other operating systems.
- Make dialogs scrollable so instruction list on smaller screens can be
read until the end.
31 lines
936 B
TypeScript
31 lines
936 B
TypeScript
import { OperatingSystem } from '@/domain/OperatingSystem';
|
|
import { IInstructionListData, IInstructionListStep } from '../InstructionListData';
|
|
|
|
export interface IInstructionsBuilderData {
|
|
readonly fileName: string;
|
|
}
|
|
|
|
export type InstructionStepBuilderType = (data: IInstructionsBuilderData) => IInstructionListStep;
|
|
|
|
export class InstructionsBuilder {
|
|
private readonly stepBuilders = new Array<InstructionStepBuilderType>();
|
|
|
|
constructor(private readonly os: OperatingSystem) {
|
|
|
|
}
|
|
|
|
public withStep(stepBuilder: InstructionStepBuilderType) {
|
|
if (!stepBuilder) { throw new Error('missing stepBuilder'); }
|
|
this.stepBuilders.push(stepBuilder);
|
|
return this;
|
|
}
|
|
|
|
public build(data: IInstructionsBuilderData): IInstructionListData {
|
|
if (!data) { throw new Error('missing data'); }
|
|
return {
|
|
operatingSystem: this.os,
|
|
steps: this.stepBuilders.map((stepBuilder) => stepBuilder(data)),
|
|
};
|
|
}
|
|
}
|