-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix knobs for widgetbook 3.0.0, fix generating widgetbook entries for…
… the whole directory at once
- Loading branch information
1 parent
54ed43a
commit 3e1c579
Showing
7 changed files
with
25 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
interface PathGenerator { | ||
prepareWidgetbookEntryFilePath(className: string): string | null; | ||
prepareWidgetbookEntryFilePath( | ||
className: string, | ||
widgetFilePath: string | ||
): string | null; | ||
} | ||
|
||
export { PathGenerator }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import { snakeCase } from "change-case"; | ||
import * as vscode from "vscode"; | ||
import { Configuration } from "../../configuration/configuration"; | ||
import { PathGenerator } from "./generator"; | ||
|
||
class PathGeneratorImpl implements PathGenerator { | ||
prepareWidgetbookEntryFilePath(className: string): string | null { | ||
const activeTextEditor = vscode.window.activeTextEditor; | ||
if (!activeTextEditor) return null; | ||
|
||
const currentPath = activeTextEditor.document.fileName; | ||
const rootDir = Configuration.rootProjectDirectoryName(); | ||
const widgetbookWidgetsDir = Configuration.widgetsDirectoryPath(); | ||
prepareWidgetbookEntryFilePath( | ||
className: string, | ||
widgetFilePath: string | ||
): string | null { | ||
const rootDirectory = Configuration.rootProjectDirectoryName(); | ||
const widgetbookWidgetsDirectory = Configuration.widgetsDirectoryPath(); | ||
const classNameSnakeCase = snakeCase(className); | ||
const projectRootPath = currentPath.substringUpToAndIncluding(rootDir); | ||
const widgetFilePath = `${projectRootPath}/${widgetbookWidgetsDir}/${classNameSnakeCase}.dart`; | ||
const projectRootPath = | ||
widgetFilePath.substringUpToAndIncluding(rootDirectory); | ||
const outputFilePath = `${projectRootPath}/${widgetbookWidgetsDirectory}/${classNameSnakeCase}.dart`; | ||
|
||
return widgetFilePath; | ||
return outputFilePath; | ||
} | ||
} | ||
export { PathGeneratorImpl }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters