Add option to select CSS framework, add Foundation as an option (#1813)
* Add option to select CSS framework, add Foundation as an option
This commit is contained in:
@@ -35,19 +35,46 @@ class PostCreateProject
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeBootstrap(Event $event)
|
||||
public static function selectFramework(Event $event)
|
||||
{
|
||||
$io = $event->getIO();
|
||||
$default_framework_pattern = '"bootstrap": ".*"';
|
||||
|
||||
$files_to_clear = [
|
||||
'assets/styles/components/_comments.scss',
|
||||
'assets/styles/components/_forms.scss',
|
||||
'assets/styles/components/_wp-classes.scss',
|
||||
'assets/styles/layouts/_header.scss',
|
||||
];
|
||||
|
||||
|
||||
if ($io->isInteractive()) {
|
||||
if ($io->askConfirmation('<info>Remove Bootstrap?</info> [<comment>y,N</comment>]? ', false)) {
|
||||
file_put_contents('package.json', str_replace(' "bootstrap": "^4.0.0-alpha.6",' . "\n", '', file_get_contents('package.json')));
|
||||
file_put_contents('assets/styles/main.scss', str_replace('@import "~bootstrap/scss/bootstrap";' . "\n", '', file_get_contents('assets/styles/main.scss')));
|
||||
file_put_contents('assets/scripts/main.js', str_replace('import \'bootstrap/dist/js/bootstrap\';' . "\n", '', file_get_contents('assets/scripts/main.js')));
|
||||
file_put_contents('assets/styles/components/_comments.scss', '');
|
||||
file_put_contents('assets/styles/components/_forms.scss', '');
|
||||
file_put_contents('assets/styles/components/_wp-classes.scss', '');
|
||||
file_put_contents('assets/styles/layouts/_header.scss', '');
|
||||
$frameworks = [
|
||||
'Bootstrap',
|
||||
'Foundation',
|
||||
'None'
|
||||
];
|
||||
$framework = $io->select('<info>Select a CSS framework</info> <comment>(Default: Bootstrap)</comment>', $frameworks, 0);
|
||||
|
||||
switch($framework) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
file_put_contents('package.json', preg_replace("/{$default_framework_pattern}/", '"foundation-sites": "6.3.0"', file_get_contents('package.json')));
|
||||
file_put_contents('assets/styles/main.scss', str_replace('@import "~bootstrap/scss/bootstrap";' . "\n", '@import "~foundation-sites/scss/foundation";' . "\n" . '@include foundation-everything;' . "\n", file_get_contents('assets/styles/main.scss')));
|
||||
file_put_contents('assets/scripts/main.js', str_replace("import 'bootstrap/dist/js/bootstrap'\n", "import 'foundation-sites/dist/js/foundation';\n", file_get_contents('assets/scripts/main.js')));
|
||||
foreach($files_to_clear as $file) {
|
||||
file_put_contents($file, '');
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
file_put_contents('package.json', preg_replace("/\s+{$default_framework_pattern},/", '', file_get_contents('package.json')));
|
||||
file_put_contents('assets/styles/main.scss', str_replace('@import "~bootstrap/scss/bootstrap";' . "\n", '', file_get_contents('assets/styles/main.scss')));
|
||||
file_put_contents('assets/scripts/main.js', str_replace("import 'bootstrap/dist/js/bootstrap';\n", '', file_get_contents('assets/scripts/main.js')));
|
||||
foreach($files_to_clear as $file) {
|
||||
file_put_contents($file, '');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user